@xeokit/xeokit-sdk 2.6.71 → 2.6.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +767 -295
- package/dist/xeokit-sdk.es.js +762 -296
- package/dist/xeokit-sdk.es5.js +535 -525
- package/dist/xeokit-sdk.min.cjs.js +8 -8
- package/dist/xeokit-sdk.min.es.js +8 -8
- package/dist/xeokit-sdk.min.es5.js +7 -7
- package/package.json +1 -1
- package/src/extras/ContextMenu/ContextMenu.js +11 -9
- package/src/plugins/AnnotationsPlugin/Annotation.js +28 -16
- package/src/plugins/NavCubePlugin/CubeTextureCanvas.js +2 -2
- package/src/plugins/NavCubePlugin/NavCubePlugin.js +10 -10
- package/src/plugins/SectionPlanesPlugin/Control.js +2 -2
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +6 -151
- package/src/plugins/lib/ui/index.js +592 -34
- package/src/viewer/scene/geometry/ReadableGeometry.js +60 -0
- package/src/viewer/scene/geometry/builders/buildPlaneGeometry.js +1 -1
- package/src/viewer/scene/scene/Scene.js +2 -3
- package/src/viewer/scene/sectionCaps/SectionCaps.js +46 -65
- package/types/plugins/NavCubePlugin/NavCubePlugin.d.ts +1 -1
- package/types/viewer/scene/ImagePlane/ImagePlane.d.ts +397 -0
- package/types/viewer/scene/ImagePlane/index.d.ts +1 -0
- package/types/viewer/scene/geometry/builders/index.d.ts +1 -0
- package/types/viewer/scene/index.d.ts +1 -0
|
@@ -613,6 +613,66 @@ class ReadableGeometry extends Geometry {
|
|
|
613
613
|
return this._obb;
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
_getMetrics() {
|
|
617
|
+
if (! ("_metrics" in this)) {
|
|
618
|
+
switch (this._state.primitiveName) {
|
|
619
|
+
case "solid":
|
|
620
|
+
case "surface":
|
|
621
|
+
case "triangles": {
|
|
622
|
+
const indices = this._state.indices;
|
|
623
|
+
const positions = this._state.positions;
|
|
624
|
+
const getPos = (i, out) => {
|
|
625
|
+
const idx = indices[i] * 3;
|
|
626
|
+
for (let j = 0; j < 3; ++j) {
|
|
627
|
+
out[j] = positions[idx + j];
|
|
628
|
+
};
|
|
629
|
+
return out;
|
|
630
|
+
};
|
|
631
|
+
const tmp = [ math.vec3(), math.vec3(), math.vec3(), math.vec3() ];
|
|
632
|
+
let totalArea = 0;
|
|
633
|
+
const centroid = math.vec3([ 0, 0, 0 ]);
|
|
634
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
635
|
+
const v0 = getPos(i, tmp[0]);
|
|
636
|
+
const v1 = getPos(i+1, tmp[1]);
|
|
637
|
+
const v2 = getPos(i+2, tmp[2]);
|
|
638
|
+
math.addVec3(v0, v1, tmp[3]);
|
|
639
|
+
math.addVec3(v2, tmp[3], tmp[3]);
|
|
640
|
+
const faceArea = math.lenVec3(
|
|
641
|
+
math.cross3Vec3(
|
|
642
|
+
math.subVec3(v1, v0, tmp[1]),
|
|
643
|
+
math.subVec3(v2, v0, tmp[2]),
|
|
644
|
+
tmp[0])) / 2;
|
|
645
|
+
totalArea += faceArea;
|
|
646
|
+
math.mulVec3Scalar(tmp[3], faceArea, tmp[3]);
|
|
647
|
+
math.addVec3(centroid, tmp[3], centroid);
|
|
648
|
+
}
|
|
649
|
+
this._metrics = { surfaceArea: totalArea, centroid: math.mulVec3Scalar(centroid, 1 / totalArea / 3, centroid) };
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
default:
|
|
653
|
+
this._metrics = { surfaceArea: 0 };
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return this._metrics;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Returns the surface area of this Mesh.
|
|
662
|
+
* @returns {number}
|
|
663
|
+
*/
|
|
664
|
+
get surfaceArea() {
|
|
665
|
+
return this._getMetrics().surfaceArea;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Returns the centroid of this Mesh.
|
|
670
|
+
* @returns {number}
|
|
671
|
+
*/
|
|
672
|
+
get centroid() {
|
|
673
|
+
return this._getMetrics().centroid;
|
|
674
|
+
}
|
|
675
|
+
|
|
616
676
|
/**
|
|
617
677
|
* Approximate number of triangles in this ReadableGeometry.
|
|
618
678
|
*
|
|
@@ -122,7 +122,7 @@ function buildPlaneGeometry(cfg = {}) {
|
|
|
122
122
|
positions[offset + 1] = centerY;
|
|
123
123
|
positions[offset + 2] = -z + centerZ;
|
|
124
124
|
|
|
125
|
-
normals[offset +
|
|
125
|
+
normals[offset + 1] = 1;
|
|
126
126
|
|
|
127
127
|
uvs[offset2] = (ix) / planeX;
|
|
128
128
|
uvs[offset2 + 1] = ((planeZ - iz) / planeZ);
|
|
@@ -347,13 +347,12 @@ class Scene extends Component {
|
|
|
347
347
|
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
348
348
|
* responsiveness. It is important to consider that each SectionPlane imposes rendering performance, so it is recommended to set this value to a quantity that aligns with
|
|
349
349
|
* your expected usage.
|
|
350
|
-
* @throws {String} Throws an exception when
|
|
350
|
+
* @throws {String} Throws an exception when canvasId or canvasElement are missing or they aren't pointing to a valid HTMLCanvasElement.
|
|
351
351
|
*/
|
|
352
352
|
constructor(viewer, cfg = {}) {
|
|
353
353
|
|
|
354
354
|
super(null, cfg);
|
|
355
|
-
|
|
356
|
-
const canvas = cfg.canvasElement || document.getElementById(cfg.canvasId);
|
|
355
|
+
const canvas = cfg.canvasElement || document.querySelector(`#${cfg.canvasId}`);
|
|
357
356
|
|
|
358
357
|
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
359
358
|
throw "Mandatory config expected: valid canvasId or canvasElement";
|
|
@@ -127,8 +127,7 @@ class SectionCaps {
|
|
|
127
127
|
if(!this._resourcesAllocated) {
|
|
128
128
|
this._resourcesAllocated = true;
|
|
129
129
|
this._sectionPlanes = [];
|
|
130
|
-
this.
|
|
131
|
-
this._indicesMap = {};
|
|
130
|
+
this._sceneModelsData = {};
|
|
132
131
|
this._dirtyMap = {};
|
|
133
132
|
this._prevIntersectionModelsMap = {};
|
|
134
133
|
this._sectionPlaneTimeout = null;
|
|
@@ -143,7 +142,8 @@ class SectionCaps {
|
|
|
143
142
|
this._sectionPlanes.push(sectionPlane);
|
|
144
143
|
sectionPlane.on('pos', onSectionPlaneUpdated);
|
|
145
144
|
sectionPlane.on('dir', onSectionPlaneUpdated);
|
|
146
|
-
sectionPlane.
|
|
145
|
+
sectionPlane.on('active', onSectionPlaneUpdated);
|
|
146
|
+
sectionPlane.once('destroyed', (() => {
|
|
147
147
|
const sectionPlaneId = sectionPlane.id;
|
|
148
148
|
if (sectionPlaneId) {
|
|
149
149
|
this._sectionPlanes = this._sectionPlanes.filter((sectionPlane) => sectionPlane.id !== sectionPlaneId);
|
|
@@ -160,14 +160,20 @@ class SectionCaps {
|
|
|
160
160
|
|
|
161
161
|
this._onTick = this.scene.on("tick", () => {
|
|
162
162
|
//on ticks we only check if there is a model that we have saved vertices for,
|
|
163
|
-
//but it's no more available on the scene
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
delete this.
|
|
168
|
-
|
|
163
|
+
//but it's no more available on the scene, or if its visibility changed
|
|
164
|
+
let dirty = false;
|
|
165
|
+
for(const sceneModelId in this._sceneModelsData) {
|
|
166
|
+
if(!this.scene.models[sceneModelId]){
|
|
167
|
+
delete this._sceneModelsData[sceneModelId];
|
|
168
|
+
dirty = true;
|
|
169
|
+
} else if (this._sceneModelsData[sceneModelId].visible !== (!!this.scene.models[sceneModelId].visible)) {
|
|
170
|
+
this._sceneModelsData[sceneModelId].visible = !!this.scene.models[sceneModelId].visible;
|
|
171
|
+
dirty = true;
|
|
169
172
|
}
|
|
170
173
|
}
|
|
174
|
+
if (dirty) {
|
|
175
|
+
this._update();
|
|
176
|
+
}
|
|
171
177
|
})
|
|
172
178
|
}
|
|
173
179
|
|
|
@@ -183,8 +189,8 @@ class SectionCaps {
|
|
|
183
189
|
this._deletePreviousModels();
|
|
184
190
|
this._updateTimeout = setTimeout(() => {
|
|
185
191
|
clearTimeout(this._updateTimeout);
|
|
186
|
-
const sceneModels = Object.
|
|
187
|
-
this._addHatches(sceneModels, this._sectionPlanes);
|
|
192
|
+
const sceneModels = Object.values(this.scene.models).filter(sceneModel => sceneModel.visible);
|
|
193
|
+
this._addHatches(sceneModels, this._sectionPlanes.filter(sectionPlane => sectionPlane.active));
|
|
188
194
|
this._setAllDirty(false);
|
|
189
195
|
}, 100);
|
|
190
196
|
}
|
|
@@ -197,21 +203,9 @@ class SectionCaps {
|
|
|
197
203
|
|
|
198
204
|
_addHatches(sceneModels, planes) {
|
|
199
205
|
|
|
200
|
-
if (planes.length <= 0) return;
|
|
201
|
-
|
|
202
206
|
planes.forEach((plane) => {
|
|
203
207
|
sceneModels.forEach((sceneModel) => {
|
|
204
|
-
|
|
205
|
-
//we create a plane equation that will be used to slice through each triangle
|
|
206
|
-
const planeEquation = {
|
|
207
|
-
A: plane.dir[0],
|
|
208
|
-
B: plane.dir[1],
|
|
209
|
-
C: plane.dir[2],
|
|
210
|
-
D: -(plane.dir[0] * plane.pos[0] + plane.dir[1] * plane.pos[1] + plane.dir[2] * plane.pos[2])
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
213
|
-
|
|
214
|
-
if(!this._doesPlaneIntersectBoundingBox(sceneModel.aabb, planeEquation)) return;
|
|
208
|
+
if(!this._doesPlaneIntersectBoundingBox(sceneModel.aabb, plane)) return;
|
|
215
209
|
|
|
216
210
|
if(!this._dirtyMap[sceneModel.id]) return;
|
|
217
211
|
|
|
@@ -233,39 +227,35 @@ class SectionCaps {
|
|
|
233
227
|
|
|
234
228
|
const object = objects[objectId];
|
|
235
229
|
|
|
236
|
-
if(!this._doesPlaneIntersectBoundingBox(object.aabb,
|
|
230
|
+
if(!this._doesPlaneIntersectBoundingBox(object.aabb, plane)) return;
|
|
237
231
|
|
|
238
|
-
if(!this.
|
|
239
|
-
this.
|
|
240
|
-
|
|
232
|
+
if(!this._sceneModelsData[sceneModel.id]) {
|
|
233
|
+
this._sceneModelsData[sceneModel.id] = {
|
|
234
|
+
verticesMap: new Map(),
|
|
235
|
+
indicesMap: new Map()
|
|
236
|
+
};
|
|
241
237
|
}
|
|
242
238
|
|
|
243
|
-
|
|
239
|
+
const sceneModelData = this._sceneModelsData[sceneModel.id];
|
|
244
240
|
|
|
245
|
-
if(!
|
|
241
|
+
if(!sceneModelData.verticesMap.has(objectId)) {
|
|
246
242
|
const isSolid = object.meshes[0].isSolid();
|
|
243
|
+
const vertices = [ ];
|
|
244
|
+
const indices = [ ];
|
|
247
245
|
if(isSolid && object.capMaterial) {
|
|
248
|
-
object.getEachVertex(
|
|
249
|
-
|
|
250
|
-
})
|
|
251
|
-
object.getEachIndex((_indices) => {
|
|
252
|
-
indices.push(_indices);
|
|
253
|
-
})
|
|
246
|
+
object.getEachVertex(v => vertices.push(v[0], v[1], v[2]));
|
|
247
|
+
object.getEachIndex(i => indices.push(i));
|
|
254
248
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
vertices = this._verticesMap[sceneModel.id].get(objectId);
|
|
260
|
-
indices = this._indicesMap[sceneModel.id].get(objectId);
|
|
249
|
+
sceneModelData.verticesMap.set(objectId, vertices);
|
|
250
|
+
sceneModelData.indicesMap.set(objectId, indices);
|
|
261
251
|
}
|
|
262
|
-
|
|
252
|
+
|
|
253
|
+
const vertices = sceneModelData.verticesMap.get(objectId);
|
|
254
|
+
const indices = sceneModelData.indicesMap.get(objectId);
|
|
255
|
+
|
|
263
256
|
const capSegments = [];
|
|
264
257
|
const vertCount = indices.length;
|
|
265
|
-
|
|
266
|
-
// Preallocate intersection result array
|
|
267
|
-
const intersectionBuffer = new Float32Array(3);
|
|
268
|
-
|
|
258
|
+
|
|
269
259
|
for (let i = 0; i < vertCount; i += 3) {
|
|
270
260
|
// Reuse triangle buffer instead of creating new arrays
|
|
271
261
|
for (let j = 0; j < 3; j++) {
|
|
@@ -282,21 +272,15 @@ class SectionCaps {
|
|
|
282
272
|
for (let i = 0; i < 3; i++) {
|
|
283
273
|
const p1 = triangle[i];
|
|
284
274
|
const p2 = triangle[(i + 1) % 3];
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
275
|
+
|
|
276
|
+
const d1 = plane.dist + math.dotVec3(plane.dir, p1);
|
|
277
|
+
const d2 = plane.dist + math.dotVec3(plane.dir, p2);
|
|
278
|
+
|
|
290
279
|
if (d1 * d2 > 0) continue;
|
|
291
|
-
|
|
280
|
+
|
|
292
281
|
const t = -d1 / (d2 - d1);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
intersectionBuffer[1] = p1[1] + t * (p2[1] - p1[1]);
|
|
296
|
-
intersectionBuffer[2] = p1[2] + t * (p2[2] - p1[2]);
|
|
297
|
-
|
|
298
|
-
// Clone the buffer for storage
|
|
299
|
-
intersections.push(new Float32Array(intersectionBuffer));
|
|
282
|
+
|
|
283
|
+
intersections.push(math.lerpVec3(t, 0, 1, p1, p2, math.vec3()));
|
|
300
284
|
}
|
|
301
285
|
|
|
302
286
|
if(intersections.length === 2) capSegments.push(intersections);
|
|
@@ -576,7 +560,7 @@ class SectionCaps {
|
|
|
576
560
|
|
|
577
561
|
}
|
|
578
562
|
|
|
579
|
-
_doesPlaneIntersectBoundingBox(bb,
|
|
563
|
+
_doesPlaneIntersectBoundingBox(bb, plane) {
|
|
580
564
|
const min = [bb[0], bb[1], bb[2]];
|
|
581
565
|
const max = [bb[3], bb[4], bb[5]];
|
|
582
566
|
|
|
@@ -596,10 +580,7 @@ class SectionCaps {
|
|
|
596
580
|
let hasNegative = false;
|
|
597
581
|
|
|
598
582
|
for (const corner of corners) {
|
|
599
|
-
const distance =
|
|
600
|
-
planeEquation.B * corner[1] +
|
|
601
|
-
planeEquation.C * corner[2] +
|
|
602
|
-
planeEquation.D;
|
|
583
|
+
const distance = plane.dist + math.dotVec3(plane.dir, corner);
|
|
603
584
|
|
|
604
585
|
if (distance > 0) hasPositive = true;
|
|
605
586
|
if (distance < 0) hasNegative = true;
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import {Component} from '../Component.js';
|
|
2
|
+
import {Node} from '../nodes/Node.js';
|
|
3
|
+
import {Mesh} from '../mesh/Mesh.js';
|
|
4
|
+
import {Texture} from '../materials/Texture.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @desc A plane-shaped 3D object containing a bitmap image.
|
|
8
|
+
*
|
|
9
|
+
* Use ````ImagePlane```` to embed bitmap images in your scenes.
|
|
10
|
+
*
|
|
11
|
+
* As shown in the examples below, ````ImagePlane```` is useful for creating ground planes from satellite maps and embedding 2D plan
|
|
12
|
+
* view images in cross-section slicing planes.
|
|
13
|
+
*
|
|
14
|
+
* # Example 1: Create a ground plane from a satellite image
|
|
15
|
+
*
|
|
16
|
+
* In our first example, we'll load the Schependomlaan model, then use
|
|
17
|
+
* an ````ImagePlane```` to create a ground plane, which will contain
|
|
18
|
+
* a satellite image sourced from Google Maps.
|
|
19
|
+
*
|
|
20
|
+
* <img src="http://xeokit.io/img/docs/ImagePlane/schependomlaanGoogleSatMapMed.png">
|
|
21
|
+
*
|
|
22
|
+
* [<img src="http://xeokit.io/img/docs/ImagePlane/ImagePlane.png">](https://xeokit.github.io/xeokit-sdk/examples/scenegraph/#ImagePlane_groundPlane)
|
|
23
|
+
*
|
|
24
|
+
* [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/scenegraph/#ImagePlane_groundPlane)]
|
|
25
|
+
*
|
|
26
|
+
* ````javascript
|
|
27
|
+
* import {Viewer, ImagePlane, XKTLoaderPlugin} from "xeokit-sdk.es.js";
|
|
28
|
+
*
|
|
29
|
+
* const viewer = new Viewer({
|
|
30
|
+
* canvasId: "myCanvas",
|
|
31
|
+
* transparent: true
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* viewer.camera.eye = [-8.31, 42.21, 54.30];
|
|
35
|
+
* viewer.camera.look = [-0.86, 15.40, 14.90];
|
|
36
|
+
* viewer.camera.up = [0.10, 0.83, -0.54];
|
|
37
|
+
*
|
|
38
|
+
* const xktLoader = new XKTLoaderPlugin(viewer);
|
|
39
|
+
*
|
|
40
|
+
* xktLoader.load({ // Load IFC model
|
|
41
|
+
* id: "myModel",
|
|
42
|
+
* src: "./models/xkt/Schependomlaan.xkt",
|
|
43
|
+
* edges: true,
|
|
44
|
+
*
|
|
45
|
+
* rotation: [0, 22, 0], // Rotate, position and scale the model to align it correctly with the ImagePlane
|
|
46
|
+
* position: [-8, 0, 15],
|
|
47
|
+
* scale: [1.1, 1.1, 1.1]
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* new ImagePlane(viewer.scene, {
|
|
51
|
+
* src: "./images/schependomlaanSatMap.png", // Google satellite image; accepted file types are PNG and JPEG
|
|
52
|
+
* visible: true, // Show the ImagePlane
|
|
53
|
+
* gridVisible: true, // Show the grid - grid is only visible when ImagePlane is also visible
|
|
54
|
+
* size: 190, // Size of ImagePlane's longest edge
|
|
55
|
+
* position: [0, -1, 0], // World-space position of ImagePlane's center
|
|
56
|
+
* rotation: [0, 0, 0], // Euler angles for X, Y and Z
|
|
57
|
+
* opacity: 1.0, // Fully opaque
|
|
58
|
+
* collidable: false, // ImagePlane does not contribute to Scene boundary
|
|
59
|
+
* clippable: true, // ImagePlane can be clipped by SectionPlanes
|
|
60
|
+
* pickable: true // Allow the ground plane to be picked
|
|
61
|
+
* });
|
|
62
|
+
* ````
|
|
63
|
+
*<br>
|
|
64
|
+
*
|
|
65
|
+
* # Example 2: Embed an image in a cross-section plane
|
|
66
|
+
*
|
|
67
|
+
* In our second example, we'll load the Schependomlaan model again, then slice it in half with
|
|
68
|
+
* a {@link SectionPlanesPlugin}, then use an ````ImagePlane```` to embed a 2D plan view image in the slicing plane.
|
|
69
|
+
*
|
|
70
|
+
* <img src="http://xeokit.io/img/docs/ImagePlane/schependomlaanPlanViewMed.png">
|
|
71
|
+
*
|
|
72
|
+
* [<img src="http://xeokit.io/img/docs/ImagePlane/ImagePlane_planView.png">](https://xeokit.github.io/xeokit-sdk/examples/scenegraph/#ImagePlane_imageInSectionPlane)
|
|
73
|
+
*
|
|
74
|
+
* [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/scenegraph/#ImagePlane_imageInSectionPlane)]
|
|
75
|
+
*
|
|
76
|
+
* ````javascript
|
|
77
|
+
* import {Viewer, XKTLoaderPlugin, SectionPlanesPlugin, ImagePlane} from "xeokit-sdk.es.js";
|
|
78
|
+
*
|
|
79
|
+
* const viewer = new Viewer({
|
|
80
|
+
* canvasId: "myCanvas",
|
|
81
|
+
* transparent: true
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* viewer.camera.eye = [-9.11, 20.01, 5.13];
|
|
85
|
+
* viewer.camera.look = [9.07, 0.77, -9.78];
|
|
86
|
+
* viewer.camera.up = [0.47, 0.76, -0.38];
|
|
87
|
+
*
|
|
88
|
+
* const xktLoader = new XKTLoaderPlugin(viewer);
|
|
89
|
+
*
|
|
90
|
+
* const sectionPlanes = new SectionPlanesPlugin(viewer, {
|
|
91
|
+
* overviewVisible: false
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* model = xktLoader.load({
|
|
95
|
+
* id: "myModel",
|
|
96
|
+
* src: "./models/xkt/schependomlaan/schependomlaan.xkt",
|
|
97
|
+
* metaModelSrc: "./metaModels/schependomlaan/metaModel.json",
|
|
98
|
+
* edges: true,
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* const sectionPlane = sectionPlanes.createSectionPlane({
|
|
102
|
+
* id: "mySectionPlane",
|
|
103
|
+
* pos: [10.95, 1.95, -10.35],
|
|
104
|
+
* dir: [0.0, -1.0, 0.0]
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* const imagePlane = new ImagePlane(viewer.scene, {
|
|
108
|
+
* src: "./images/schependomlaanPlanView.png", // Plan view image; accepted file types are PNG and JPEG
|
|
109
|
+
* visible: true,
|
|
110
|
+
* gridVisible: true,
|
|
111
|
+
* size: 23.95,
|
|
112
|
+
* position: sectionPlane.pos,
|
|
113
|
+
* dir: sectionPlane.dir,
|
|
114
|
+
* collidable: false,
|
|
115
|
+
* opacity: 0.75,
|
|
116
|
+
* clippable: false, // Don't allow ImagePlane to be clipped by the SectionPlane
|
|
117
|
+
* pickable: false // Don't allow ImagePlane to be picked
|
|
118
|
+
* });
|
|
119
|
+
* ````
|
|
120
|
+
*/
|
|
121
|
+
export declare class ImagePlane extends Component {
|
|
122
|
+
/**
|
|
123
|
+
* @constructor
|
|
124
|
+
* @param {Component} [owner] Owner component. When destroyed, the owner will destroy this ImagePlane as well.
|
|
125
|
+
* @param {*} [cfg] ImagePlane configuration
|
|
126
|
+
* @param {String} [cfg.id] Optional ID, unique among all components in the parent Scene, generated automatically when omitted.
|
|
127
|
+
* @param {Boolean} [cfg.visible=true] Indicates whether or not this ImagePlane is visible.
|
|
128
|
+
* @param {Boolean} [cfg.gridVisible=true] Indicates whether or not the grid is visible. Grid is only visible when ImagePlane is also visible.
|
|
129
|
+
* @param {Number[]} [cfg.position=[0,0,0]] World-space position of the ImagePlane.
|
|
130
|
+
* @param {Number[]} [cfg.size=1] World-space size of the longest edge of the ImagePlane.
|
|
131
|
+
* @param {Number[]} [cfg.rotation=[0,0,0]] Local rotation of the ImagePlane, as Euler angles given in degrees, for each of the X, Y and Z axis.
|
|
132
|
+
* @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Modelling transform matrix for the ImagePlane. Overrides the position, size, rotation and dir parameters.
|
|
133
|
+
* @param {Boolean} [cfg.collidable=true] Indicates if the ImagePlane is initially included in boundary calculations.
|
|
134
|
+
* @param {Boolean} [cfg.clippable=true] Indicates if the ImagePlane is initially clippable.
|
|
135
|
+
* @param {Boolean} [cfg.pickable=true] Indicates if the ImagePlane is initially pickable.
|
|
136
|
+
* @param {Number} [cfg.opacity=1.0] ImagePlane's initial opacity factor, multiplies by the rendered fragment alpha.
|
|
137
|
+
* @param {String} [cfg.src] URL of image. Accepted file types are PNG and JPEG.
|
|
138
|
+
* @param {HTMLImageElement} [cfg.image] An HTMLImageElement to source the image from. Overrides src.
|
|
139
|
+
*/
|
|
140
|
+
constructor(owner: Component, cfg?: {
|
|
141
|
+
id?: string;
|
|
142
|
+
visible?: boolean;
|
|
143
|
+
gridVisible?: boolean;
|
|
144
|
+
position?: number[];
|
|
145
|
+
size?: number;
|
|
146
|
+
rotation?: number[];
|
|
147
|
+
matrix?: number[];
|
|
148
|
+
collidable?: boolean;
|
|
149
|
+
clippable?: boolean;
|
|
150
|
+
pickable?: boolean;
|
|
151
|
+
opacity?: number;
|
|
152
|
+
src?: string;
|
|
153
|
+
image?: HTMLImageElement;
|
|
154
|
+
dir?: number[];
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Sets if this ````ImagePlane```` is visible or not.
|
|
159
|
+
*
|
|
160
|
+
* Default value is ````true````.
|
|
161
|
+
*
|
|
162
|
+
* @param {Boolean} visible Set ````true```` to make this ````ImagePlane```` visible.
|
|
163
|
+
*/
|
|
164
|
+
set visible(visible: boolean);
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Gets if this ````ImagePlane```` is visible or not.
|
|
168
|
+
*
|
|
169
|
+
* Default value is ````true````.
|
|
170
|
+
*
|
|
171
|
+
* @returns {Boolean} Returns ````true```` if visible.
|
|
172
|
+
*/
|
|
173
|
+
get visible(): boolean;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Sets if this ````ImagePlane````'s grid is visible or not.
|
|
177
|
+
*
|
|
178
|
+
* Default value is ````false````.
|
|
179
|
+
*
|
|
180
|
+
* Grid is only visible when ````ImagePlane```` is also visible.
|
|
181
|
+
*
|
|
182
|
+
* @param {Boolean} visible Set ````true```` to make this ````ImagePlane````'s grid visible.
|
|
183
|
+
*/
|
|
184
|
+
set gridVisible(visible: boolean);
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Gets if this ````ImagePlane````'s grid is visible or not.
|
|
188
|
+
*
|
|
189
|
+
* Default value is ````false````.
|
|
190
|
+
*
|
|
191
|
+
* @returns {Boolean} Returns ````true```` if visible.
|
|
192
|
+
*/
|
|
193
|
+
get gridVisible(): boolean;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Sets an ````HTMLImageElement```` to source the image from.
|
|
197
|
+
*
|
|
198
|
+
* Sets {@link Texture#src} null.
|
|
199
|
+
*
|
|
200
|
+
* @type {HTMLImageElement}
|
|
201
|
+
*/
|
|
202
|
+
set image(image: HTMLImageElement | null);
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Gets the ````HTMLImageElement```` the ````ImagePlane````'s image is sourced from, if set.
|
|
206
|
+
*
|
|
207
|
+
* Returns null if not set.
|
|
208
|
+
*
|
|
209
|
+
* @type {HTMLImageElement}
|
|
210
|
+
*/
|
|
211
|
+
get image(): HTMLImageElement | null;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Sets an image file path that the ````ImagePlane````'s image is sourced from.
|
|
215
|
+
*
|
|
216
|
+
* Accepted file types are PNG and JPEG.
|
|
217
|
+
*
|
|
218
|
+
* Sets {@link Texture#image} null.
|
|
219
|
+
*
|
|
220
|
+
* @type {String}
|
|
221
|
+
*/
|
|
222
|
+
set src(src: string | null);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Gets the image file path that the ````ImagePlane````'s image is sourced from, if set.
|
|
226
|
+
*
|
|
227
|
+
* Returns null if not set.
|
|
228
|
+
*
|
|
229
|
+
* @type {String}
|
|
230
|
+
*/
|
|
231
|
+
get src(): string | null;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Sets the World-space position of this ````ImagePlane````.
|
|
235
|
+
*
|
|
236
|
+
* Default value is ````[0, 0, 0]````.
|
|
237
|
+
*
|
|
238
|
+
* @param {Number[]} value New position.
|
|
239
|
+
*/
|
|
240
|
+
set position(value: number[]);
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Gets the World-space position of this ````ImagePlane````.
|
|
244
|
+
*
|
|
245
|
+
* Default value is ````[0, 0, 0]````.
|
|
246
|
+
*
|
|
247
|
+
* @returns {Number[]} Current position.
|
|
248
|
+
*/
|
|
249
|
+
get position(): number[];
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Sets the direction of this ````ImagePlane```` using Euler angles.
|
|
253
|
+
*
|
|
254
|
+
* Default value is ````[0, 0, 0]````.
|
|
255
|
+
*
|
|
256
|
+
* @param {Number[]} value Euler angles for ````X````, ````Y```` and ````Z```` axis rotations.
|
|
257
|
+
*/
|
|
258
|
+
set rotation(value: number[]);
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Gets the direction of this ````ImagePlane```` as Euler angles.
|
|
262
|
+
*
|
|
263
|
+
* @returns {Number[]} Euler angles for ````X````, ````Y```` and ````Z```` axis rotations.
|
|
264
|
+
*/
|
|
265
|
+
get rotation(): number[];
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Sets the World-space size of the longest edge of the ````ImagePlane````.
|
|
269
|
+
*
|
|
270
|
+
* Note that ````ImagePlane```` sets its aspect ratio to match its image. If we set a value of ````1000````, and
|
|
271
|
+
* the image has size ````400x300````, then the ````ImagePlane```` will then have size ````1000 x 750````.
|
|
272
|
+
*
|
|
273
|
+
* Default value is ````1.0````.
|
|
274
|
+
*
|
|
275
|
+
* @param {Number} size New World-space size of the ````ImagePlane````.
|
|
276
|
+
*/
|
|
277
|
+
set size(size: number);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Gets the World-space size of the longest edge of the ````ImagePlane````.
|
|
281
|
+
*
|
|
282
|
+
* @returns {Number} World-space size of the ````ImagePlane````.
|
|
283
|
+
*/
|
|
284
|
+
get size(): number;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Sets the direction of this ````ImagePlane```` as a direction vector.
|
|
288
|
+
*
|
|
289
|
+
* Default value is ````[0, 0, -1]````.
|
|
290
|
+
*
|
|
291
|
+
* @param {Number[]} dir New direction vector.
|
|
292
|
+
*/
|
|
293
|
+
set dir(dir: number[]);
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Gets the direction of this ````ImagePlane```` as a direction vector.
|
|
297
|
+
*
|
|
298
|
+
* @returns {Number[]} value Current direction.
|
|
299
|
+
*/
|
|
300
|
+
get dir(): number[];
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Sets if this ````ImagePlane```` is included in boundary calculations.
|
|
304
|
+
*
|
|
305
|
+
* Default is ````true````.
|
|
306
|
+
*
|
|
307
|
+
* @type {Boolean}
|
|
308
|
+
*/
|
|
309
|
+
set collidable(value: boolean);
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Gets if this ````ImagePlane```` is included in boundary calculations.
|
|
313
|
+
*
|
|
314
|
+
* Default is ````true````.
|
|
315
|
+
*
|
|
316
|
+
* @type {Boolean}
|
|
317
|
+
*/
|
|
318
|
+
get collidable(): boolean;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Sets if this ````ImagePlane```` is clippable.
|
|
322
|
+
*
|
|
323
|
+
* Clipping is done by the {@link SectionPlane}s in {@link Scene#sectionPlanes}.
|
|
324
|
+
*
|
|
325
|
+
* Default is ````true````.
|
|
326
|
+
*
|
|
327
|
+
* @type {Boolean}
|
|
328
|
+
*/
|
|
329
|
+
set clippable(value: boolean);
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Gets if this ````ImagePlane```` is clippable.
|
|
333
|
+
*
|
|
334
|
+
* Clipping is done by the {@link SectionPlane}s in {@link Scene#sectionPlanes}.
|
|
335
|
+
*
|
|
336
|
+
* Default is ````true````.
|
|
337
|
+
*
|
|
338
|
+
* @type {Boolean}
|
|
339
|
+
*/
|
|
340
|
+
get clippable(): boolean;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Sets if this ````ImagePlane```` is pickable.
|
|
344
|
+
*
|
|
345
|
+
* Default is ````true````.
|
|
346
|
+
*
|
|
347
|
+
* @type {Boolean}
|
|
348
|
+
*/
|
|
349
|
+
set pickable(value: boolean);
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Gets if this ````ImagePlane```` is pickable.
|
|
353
|
+
*
|
|
354
|
+
* Default is ````true````.
|
|
355
|
+
*
|
|
356
|
+
* @type {Boolean}
|
|
357
|
+
*/
|
|
358
|
+
get pickable(): boolean;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Sets the opacity factor for this ````ImagePlane````.
|
|
362
|
+
*
|
|
363
|
+
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
|
364
|
+
*
|
|
365
|
+
* @type {Number}
|
|
366
|
+
*/
|
|
367
|
+
set opacity(opacity: number);
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Gets this ````ImagePlane````'s opacity factor.
|
|
371
|
+
*
|
|
372
|
+
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
|
373
|
+
*
|
|
374
|
+
* @type {Number}
|
|
375
|
+
*/
|
|
376
|
+
get opacity(): number;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @destroy
|
|
380
|
+
*/
|
|
381
|
+
destroy(): void;
|
|
382
|
+
|
|
383
|
+
protected _node: Node;
|
|
384
|
+
protected _plane: Mesh;
|
|
385
|
+
protected _grid: Mesh;
|
|
386
|
+
protected _texture: Texture;
|
|
387
|
+
protected _src: string | null;
|
|
388
|
+
protected _image: HTMLImageElement | null;
|
|
389
|
+
protected _pos: Float32Array;
|
|
390
|
+
protected _origin: Float32Array;
|
|
391
|
+
protected _rtcPos: Float32Array;
|
|
392
|
+
protected _dir: Float32Array;
|
|
393
|
+
protected _size: number;
|
|
394
|
+
protected _imageSize: Float32Array;
|
|
395
|
+
protected _gridVisible: boolean;
|
|
396
|
+
protected _updatePlaneSizeFromImage(): void;
|
|
397
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ImagePlane";
|