Parameters
Display oriented images in 3D space.
import { MapControls } from "three/examples/jsm/controls/MapControls.js";
import CoordinateSystem from "@giro3d/giro3d/core/geographic/CoordinateSystem.js";
import Instance from "@giro3d/giro3d/core/Instance.js";
import OrientedImageCollection from "@giro3d/giro3d/entities/OrientedImageCollection.js";
import PointCloud from "@giro3d/giro3d/entities/PointCloud.js";
import Inspector from "@giro3d/giro3d/gui/Inspector.js";
import COPCSource from "@giro3d/giro3d/sources/COPCSource.js";
function bindToggle(id, onChange) {
const element = document.getElementById(id);
if (!(element instanceof HTMLInputElement)) {
throw new Error(
"invalid binding element: expected HTMLButtonElement, got: " +
element.constructor.name,
);
}
element.oninput = function oninput() {
onChange(element.checked);
};
const callback = (v) => {
element.checked = v;
onChange(element.checked);
};
return [callback, element.checked, element];
}
const crs = CoordinateSystem.register(
"EPSG:32615",
`
PROJCRS["WGS 84 / UTM zone 15N",
BASEGEOGCRS["WGS 84",
ENSEMBLE["World Geodetic System 1984 ensemble",
MEMBER["World Geodetic System 1984 (Transit)"],
MEMBER["World Geodetic System 1984 (G730)"],
MEMBER["World Geodetic System 1984 (G873)"],
MEMBER["World Geodetic System 1984 (G1150)"],
MEMBER["World Geodetic System 1984 (G1674)"],
MEMBER["World Geodetic System 1984 (G1762)"],
MEMBER["World Geodetic System 1984 (G2139)"],
MEMBER["World Geodetic System 1984 (G2296)"],
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ENSEMBLEACCURACY[2.0]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]],
CONVERSION["UTM zone 15N",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",-93,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",0.9996,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",500000,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",east,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["(N)",north,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Navigation and medium accuracy spatial referencing."],
AREA["Between 96°W and 90°W, northern hemisphere between equator and 84°N, onshore and offshore. Canada - Manitoba; Nunavut; Ontario. Ecuador -Galapagos. Guatemala. Mexico. United States (USA)."],
BBOX[0,-96,84,-90]],
ID["EPSG",32615]]`,
);
const instance = new Instance({
target: "view",
crs,
backgroundColor: null,
});
const pointCloud = new PointCloud({
source: new COPCSource({
url: "https://3d.oslandia.com/giro3d/drone/brighton-beach/model.copc.laz",
}),
});
instance.add(pointCloud).then(() => {
const pov = instance.view.goTo(pointCloud);
const controls = new MapControls(instance.view.camera, instance.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.2;
controls.target.copy(pov.target);
controls.saveState();
instance.view.setControls(controls);
});
const orientedImageCollection = new OrientedImageCollection({
locationSpheres: {
visible: true,
radius: 0.5,
color: "red",
},
frustums: {
visible: true,
color: "yellow",
},
images: {
visible: true,
},
source: {
images: [
{
position: { x: 576699.898987649, y: 5188128.736938151, z: 198.6 },
distance: 10,
aspectRatio: 1.77,
fov: 47.6365,
orientation: { heading: 44.2, pitch: -89.9, roll: 0 },
imageUrl:
"https://3d.oslandia.com/giro3d/drone/brighton-beach/images/DJI_0030.webp",
},
{
position: { x: 576709.723136936, y: 5188139.050652663, z: 198.7 },
distance: 10,
aspectRatio: 1.77,
fov: 47.6365,
orientation: { heading: 41.4, pitch: -89.9, roll: 0 },
imageUrl:
"https://3d.oslandia.com/giro3d/drone/brighton-beach/images/DJI_0031.webp",
},
{
position: { x: 576718.9197612616, y: 5188148.738897609, z: 198.6 },
distance: 10,
aspectRatio: 1.77,
fov: 47.6365,
orientation: { heading: 42.8, pitch: -89.9, roll: 0 },
imageUrl:
"https://3d.oslandia.com/giro3d/drone/brighton-beach/images/DJI_0032.webp",
},
{
position: { x: 576728.5399550111, y: 5188158.432584833, z: 198.6 },
distance: 10,
aspectRatio: 1.77,
fov: 47.6365,
orientation: { heading: 42, pitch: -89.9, roll: 2.3 },
imageUrl:
"https://3d.oslandia.com/giro3d/drone/brighton-beach/images/DJI_0033.webp",
},
{
position: { x: 576737.9483180544, y: 5188168.123573817, z: 198.5 },
distance: 10,
aspectRatio: 1.77,
fov: 47.6365,
orientation: { heading: 44.7, pitch: -89.9, roll: 0 },
imageUrl:
"https://3d.oslandia.com/giro3d/drone/brighton-beach/images/DJI_0034.webp",
},
{
position: { x: 576747.1448514065, y: 5188177.811863552, z: 198.5 },
distance: 10,
aspectRatio: 1.77,
fov: 47.6365,
orientation: { heading: 45.3, pitch: -89.9, roll: 0 },
imageUrl:
"https://3d.oslandia.com/giro3d/drone/brighton-beach/images/DJI_0035.webp",
},
],
},
});
instance.add(orientedImageCollection).catch(console.error);
Inspector.attach("inspector", instance);
bindToggle("show-frustums", (v) => (orientedImageCollection.showFrustums = v));
bindToggle("show-images", (v) => (orientedImageCollection.showImages = v));
bindToggle(
"show-origins",
(v) => (orientedImageCollection.showLocationSpheres = v),
);
<!doctype html>
<html lang="en">
<head>
<title>Oriented Images</title>
<meta charset="UTF-8" />
<meta name="name" content="oriented-image-collection" />
<meta name="description" content="Display oriented images in 3D space." />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="https://giro3d.org/images/favicon.svg" />
<link
href="https://giro3d.org/assets/bootstrap-custom.css"
rel="stylesheet"
/>
<script src="https://giro3d.org/assets/bootstrap.bundle.min.js"></script>
<link
rel="stylesheet"
type="text/css"
href="https://giro3d.org/latest/examples/css/example.css"
/>
<style>
#view canvas {
background: rgb(132, 170, 182);
background: radial-gradient(
circle,
rgba(132, 170, 182, 1) 0%,
rgba(37, 44, 48, 1) 100%
);
}
</style>
</head>
<body>
<div id="view" class="m-0 p-0 w-100 h-100"></div>
<div
id="inspector"
class="position-absolute top-0 start-0 mh-100 overflow-auto"
></div>
<div class="side-pane-with-status-bar">
<div class="card">
<div class="card-header">Parameters</div>
<div class="card-body">
<!-- Show/Hide images -->
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
checked="true"
role="switch"
id="show-images"
autocomplete="off"
/>
<label class="form-check-label" for="show-images"
>Show images</label
>
</div>
<!-- Show/Hide origins -->
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
checked="true"
role="switch"
id="show-origins"
autocomplete="off"
/>
<label class="form-check-label" for="show-origins"
>Show origins</label
>
</div>
<!-- Show/Hide frustums -->
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
checked="true"
role="switch"
id="show-frustums"
autocomplete="off"
/>
<label class="form-check-label" for="show-frustums"
>Show frustums</label
>
</div>
</div>
</div>
</div>
<script type="module" src="index.js"></script>
<script>
/* activate popovers */
const popoverTriggerList = [].slice.call(
document.querySelectorAll('[data-bs-toggle="popover"]'),
);
popoverTriggerList.map(
// bootstrap is used as script in the template, disable warning about undef
// eslint-disable-next-line no-undef
(popoverTriggerEl) =>
new bootstrap.Popover(popoverTriggerEl, {
trigger: "hover",
placement: "left",
content: document.getElementById(
popoverTriggerEl.getAttribute("data-bs-content"),
).innerHTML,
html: true,
}),
);
</script>
</body>
</html>
{
"name": "oriented-image-collection",
"dependencies": {
"@giro3d/giro3d": "1.0.0"
},
"devDependencies": {
"vite": "^3.2.3"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}
import { defineConfig } from "vite";
export default defineConfig({
build: {
target: 'esnext',
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext',
},
},
})