@xeokit/xeokit-sdk 2.6.6 → 2.6.8
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/README.md +20 -14
- package/dist/xeokit-sdk.cjs.js +317 -46
- package/dist/xeokit-sdk.es.js +317 -46
- package/dist/xeokit-sdk.es5.js +847 -696
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/viewer/scene/model/vbo/VBORenderer.js +10 -1
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesColorRenderer.js +2 -2
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesEmphasisRenderer.js +3 -3
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +14 -8
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorTextureRenderer.js +10 -4
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesFlatColorRenderer.js +10 -4
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSilhouetteRenderer.js +16 -8
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesColorRenderer.js +1 -2
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesEmphasisRenderer.js +1 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +10 -4
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorTextureRenderer.js +12 -6
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatColorRenderer.js +17 -11
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSilhouetteRenderer.js +15 -6
- package/src/viewer/scene/postfx/CrossSections.js +203 -0
- package/src/viewer/scene/scene/Scene.js +10 -1
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.d.ts +3 -1
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.d.ts +2 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.d.ts +2 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.d.ts +2 -0
- package/types/viewer/scene/postfx/CrossSections.d.ts +42 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {Component} from '../Component.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc Configures cross-section slices for a {@link Scene}.
|
|
5
|
+
*
|
|
6
|
+
* ## Overview
|
|
7
|
+
*
|
|
8
|
+
* Cross-sections allow to create an additional colored slice for used clipping planes. It is only a visual effect
|
|
9
|
+
* calculated by shaders. It makes it easier to see the intersection between the model and the clipping plane this way.
|
|
10
|
+
*
|
|
11
|
+
* ## Usage
|
|
12
|
+
*
|
|
13
|
+
* In the example below, we'll configure CrossSections to manipulate the slice representation.
|
|
14
|
+
*
|
|
15
|
+
* ````javascript
|
|
16
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
17
|
+
* // Import the modules we need for this example
|
|
18
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
19
|
+
*
|
|
20
|
+
* import {PhongMaterial, Viewer, math, SectionPlanesPlugin, XKTLoaderPlugin, Mesh, ReadableGeometry, buildPolylineGeometryFromCurve, SplineCurve} from "../../dist/xeokit-sdk.es.js";
|
|
21
|
+
*
|
|
22
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
23
|
+
* // Create a Viewer and arrange the camera
|
|
24
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
25
|
+
*
|
|
26
|
+
* const viewer = new Viewer({
|
|
27
|
+
* canvasId: "myCanvas",
|
|
28
|
+
* transparent: true
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* viewer.camera.eye = [-2.341298674548419, 22.43987089731119, 7.236688436028655];
|
|
32
|
+
* viewer.camera.look = [4.399999999999963, 3.7240000000000606, 8.899000000000006];
|
|
33
|
+
* viewer.camera.up = [0.9102954845584759, 0.34781746407929504, 0.22446635042673466];
|
|
34
|
+
*
|
|
35
|
+
* const cameraControl = viewer.cameraControl;
|
|
36
|
+
* cameraControl.navMode = "orbit";
|
|
37
|
+
* cameraControl.followPointer = true;
|
|
38
|
+
*
|
|
39
|
+
* //----------------------------------------------------------------------------------------------------------------------
|
|
40
|
+
* // Create a xeokit loader plugin, load a model, fit to view
|
|
41
|
+
* //----------------------------------------------------------------------------------------------------------------------
|
|
42
|
+
*
|
|
43
|
+
* const xktLoader = new XKTLoaderPlugin(viewer);
|
|
44
|
+
*
|
|
45
|
+
* var t0 = performance.now();
|
|
46
|
+
*
|
|
47
|
+
* document.getElementById("time").innerHTML = "Loading model...";
|
|
48
|
+
*
|
|
49
|
+
* const sceneModel = xktLoader.load({
|
|
50
|
+
* id: "myModel",
|
|
51
|
+
* src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
|
|
52
|
+
* edges: true
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* sceneModel.on("loaded", () => {
|
|
56
|
+
* var t1 = performance.now();
|
|
57
|
+
* document.getElementById("time").innerHTML = "Model loaded in " + Math.floor(t1 - t0) / 1000.0 + " seconds<br>Objects: " + sceneModel.numEntities;
|
|
58
|
+
*
|
|
59
|
+
* let path = new SplineCurve(viewer.scene, {
|
|
60
|
+
* points: [
|
|
61
|
+
* [0, 0, -10],
|
|
62
|
+
* [0, 0, -3],
|
|
63
|
+
* [10, 0, 10],
|
|
64
|
+
* [10, 0, 30],
|
|
65
|
+
* ],
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* new Mesh(viewer.scene, {
|
|
69
|
+
* geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometryFromCurve({
|
|
70
|
+
* id: "SplineCurve",
|
|
71
|
+
* curve: path,
|
|
72
|
+
* divisions: 50,
|
|
73
|
+
* })),
|
|
74
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
75
|
+
* emissive: [1, 0, 0]
|
|
76
|
+
* })
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
80
|
+
* // Create a moving SectionPlane, that moves through the table models
|
|
81
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
82
|
+
*
|
|
83
|
+
* const sectionPlanes = new SectionPlanesPlugin(viewer, {
|
|
84
|
+
* overviewCanvasId: "mySectionPlanesOverviewCanvas",
|
|
85
|
+
* overviewVisible: true
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* let currentPoint = path.getPoint(0);
|
|
89
|
+
* let currentDirection = path.getTangent(0);
|
|
90
|
+
*
|
|
91
|
+
* const sectionPlane = sectionPlanes.createSectionPlane({
|
|
92
|
+
* id: "mySectionPlane",
|
|
93
|
+
* pos: currentPoint,
|
|
94
|
+
* dir: currentDirection
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* sectionPlanes.showControl(sectionPlane.id);
|
|
98
|
+
*
|
|
99
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
100
|
+
* // Controlling SectionPlane position and direction
|
|
101
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
102
|
+
*
|
|
103
|
+
* let currentT = 0.0;
|
|
104
|
+
* document.getElementById("section_path").oninput = function() {
|
|
105
|
+
* currentT = Number(document.getElementById("section_path").value);
|
|
106
|
+
* currentPoint = path.getPoint(currentT);
|
|
107
|
+
* currentDirection = path.getTangent(currentT);
|
|
108
|
+
* sectionPlane.pos = currentPoint;
|
|
109
|
+
* sectionPlane.dir = currentDirection;
|
|
110
|
+
* };
|
|
111
|
+
*
|
|
112
|
+
* window.viewer = viewer;
|
|
113
|
+
*
|
|
114
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
115
|
+
* // Controlling CrossSections settings
|
|
116
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
117
|
+
*
|
|
118
|
+
* viewer.scene.crossSections.sliceThickness = 0.05;
|
|
119
|
+
* viewer.scene.crossSections.sliceColor = [0.0, 0.0, 0.0, 1.0];
|
|
120
|
+
* });
|
|
121
|
+
* ````
|
|
122
|
+
*
|
|
123
|
+
* [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/slicing/#SectionPlanesPlugin_Duplex_SectionPath_CrossSections)]
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
class CrossSections extends Component {
|
|
127
|
+
|
|
128
|
+
/** @private */
|
|
129
|
+
constructor(owner, cfg = {}) {
|
|
130
|
+
|
|
131
|
+
super(owner, cfg);
|
|
132
|
+
|
|
133
|
+
this.sliceColor = cfg.sliceColor;
|
|
134
|
+
this.sliceThickness = cfg.sliceThickness;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Sets the thickness of a slice created by a section.
|
|
139
|
+
*
|
|
140
|
+
* Default value is ````0.0````.
|
|
141
|
+
*
|
|
142
|
+
* @type {Number}
|
|
143
|
+
*/
|
|
144
|
+
set sliceThickness(value) {
|
|
145
|
+
if (value === undefined || value === null) {
|
|
146
|
+
value = 0.0;
|
|
147
|
+
}
|
|
148
|
+
if (this._sliceThickness === value) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this._sliceThickness = value;
|
|
152
|
+
this.glRedraw();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Gets the thickness of a slice created by a section.
|
|
157
|
+
*
|
|
158
|
+
* Default value is ````0.0````.
|
|
159
|
+
*
|
|
160
|
+
* @type {Number}
|
|
161
|
+
*/
|
|
162
|
+
get sliceThickness() {
|
|
163
|
+
return this._sliceThickness;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Sets the color of a slice created by a section.
|
|
168
|
+
*
|
|
169
|
+
* Default value is ````[0.0, 0.0, 0.0, 1.0]````.
|
|
170
|
+
*
|
|
171
|
+
* @type {Number}
|
|
172
|
+
*/
|
|
173
|
+
set sliceColor(value) {
|
|
174
|
+
if (value === undefined || value === null) {
|
|
175
|
+
value = [0.0, 0.0, 0.0, 1.0];
|
|
176
|
+
}
|
|
177
|
+
if (this._sliceColor === value) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this._sliceColor = value;
|
|
181
|
+
this.glRedraw();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Gets the color of a slice created by a section.
|
|
186
|
+
*
|
|
187
|
+
* Default value is ````[0.0, 0.0, 0.0, 1.0]````.
|
|
188
|
+
*
|
|
189
|
+
* @type {Number}
|
|
190
|
+
*/
|
|
191
|
+
get sliceColor() {
|
|
192
|
+
return this._sliceColor;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Destroys this component.
|
|
197
|
+
*/
|
|
198
|
+
destroy() {
|
|
199
|
+
super.destroy();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export {CrossSections};
|
|
@@ -16,6 +16,7 @@ import {EmphasisMaterial} from '../materials/EmphasisMaterial.js';
|
|
|
16
16
|
import {EdgeMaterial} from '../materials/EdgeMaterial.js';
|
|
17
17
|
import {Metrics} from "../metriqs/Metriqs.js";
|
|
18
18
|
import {SAO} from "../postfx/SAO.js";
|
|
19
|
+
import {CrossSections} from "../postfx/CrossSections.js";
|
|
19
20
|
import {PointsMaterial} from "../materials/PointsMaterial.js";
|
|
20
21
|
import {LinesMaterial} from "../materials/LinesMaterial.js";
|
|
21
22
|
|
|
@@ -840,6 +841,14 @@ class Scene extends Component {
|
|
|
840
841
|
enabled: cfg.saoEnabled
|
|
841
842
|
});
|
|
842
843
|
|
|
844
|
+
/** Configures Cross Sections for this Scene.
|
|
845
|
+
* @type {CrossSections}
|
|
846
|
+
* @final
|
|
847
|
+
*/
|
|
848
|
+
this.crossSections = new CrossSections(this, {
|
|
849
|
+
|
|
850
|
+
});
|
|
851
|
+
|
|
843
852
|
this.ticksPerRender = cfg.ticksPerRender;
|
|
844
853
|
this.ticksPerOcclusionTest = cfg.ticksPerOcclusionTest;
|
|
845
854
|
this.passes = cfg.passes;
|
|
@@ -2799,4 +2808,4 @@ class Scene extends Component {
|
|
|
2799
2808
|
}
|
|
2800
2809
|
}
|
|
2801
2810
|
|
|
2802
|
-
export {Scene};
|
|
2811
|
+
export {Scene};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {AngleMeasurementsControl} from "./AngleMeasurementsControl.js";
|
|
2
2
|
import {AngleMeasurementsPlugin} from "./AngleMeasurementsPlugin";
|
|
3
3
|
import {PointerLens} from "../../extras/";
|
|
4
4
|
|
|
@@ -42,11 +42,13 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
42
42
|
* @param {AngleMeasurementsPlugin} angleMeasurementsPlugin The AngleMeasurementsPlugin to control.
|
|
43
43
|
* @param {Object} [cfg] Configuration options.
|
|
44
44
|
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use for providing a magnified view of the cursor when snapping is enabled.
|
|
45
|
+
* @param {function} [cfg.canvasToPagePos] Optional function to map canvas-space coordinates to page coordinates.
|
|
45
46
|
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
|
|
46
47
|
*/
|
|
47
48
|
constructor(angleMeasurementsPlugin: AngleMeasurementsPlugin, cfg?: {
|
|
48
49
|
pointerLens?: PointerLens;
|
|
49
50
|
snapping?: boolean;
|
|
51
|
+
canvasToPagePos? : Function;
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -42,11 +42,13 @@ export class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
|
|
|
42
42
|
* @param {AngleMeasurementsPlugin} angleMeasurementsPlugin The AngleMeasurementsPlugin to control.
|
|
43
43
|
* @param {Object} [cfg] Configuration options.
|
|
44
44
|
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use for providing a magnified view of the cursor when snapping is enabled.
|
|
45
|
+
* @param {function} [cfg.canvasToPagePos] Optional function to map canvas-space coordinates to page coordinates.
|
|
45
46
|
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsTouchControl.
|
|
46
47
|
*/
|
|
47
48
|
constructor(angleMeasurementsPlugin: AngleMeasurementsPlugin, cfg?: {
|
|
48
49
|
pointerLens?: PointerLens;
|
|
49
50
|
snapping?: boolean;
|
|
51
|
+
canvasToPagePos? : Function;
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -21,11 +21,13 @@ export class DistanceMeasurementsMouseControl extends DistanceMeasurementsContro
|
|
|
21
21
|
* @param {DistanceMeasurementsPlugin} distanceMeasurementsPlugin The DistanceMeasurementsPlugin to control.
|
|
22
22
|
* @param {Object} cfg Configuration options.
|
|
23
23
|
* @param {PointerLens} [cfg.pointerLens] A PointerLens to provide a magnified view of the cursor when snapping is enabled.
|
|
24
|
+
* @param {function} [cfg.canvasToPagePos] Optional function to map canvas-space coordinates to page coordinates.
|
|
24
25
|
* @param {boolean} [cfg.snapping=true] Whether to enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
|
|
25
26
|
*/
|
|
26
27
|
constructor(distanceMeasurementsPlugin: DistanceMeasurementsPlugin, cfg?: {
|
|
27
28
|
pointerLens?: PointerLens;
|
|
28
29
|
snapping?: boolean;
|
|
30
|
+
canvasToPagePos? : Function;
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -20,11 +20,13 @@ export class DistanceMeasurementsTouchControl extends DistanceMeasurementsContro
|
|
|
20
20
|
* @param {DistanceMeasurementsPlugin} distanceMeasurementsPlugin The DistanceMeasurementsPlugin to control.
|
|
21
21
|
* @param {Object} cfg Configuration options.
|
|
22
22
|
* @param {PointerLens} [cfg.pointerLens] A PointerLens to provide a magnified view of the cursor when snapping is enabled.
|
|
23
|
+
* @param {function} [cfg.canvasToPagePos] Optional function to map canvas-space coordinates to page coordinates.
|
|
23
24
|
* @param {boolean} [cfg.snapping=true] Whether to enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsTouchControl.
|
|
24
25
|
*/
|
|
25
26
|
constructor(distanceMeasurementsPlugin: DistanceMeasurementsPlugin, cfg?: {
|
|
26
27
|
pointerLens?: PointerLens;
|
|
27
28
|
snapping?: boolean;
|
|
29
|
+
canvasToPagePos? : Function;
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Component } from "../Component";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc Configures cross-section slices for a {@link Scene}.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CrossSections extends Component {
|
|
7
|
+
/**
|
|
8
|
+
* Sets the thickness of a slice created by a section.
|
|
9
|
+
*
|
|
10
|
+
* Default value is ````0.0````.
|
|
11
|
+
*
|
|
12
|
+
* @type {Number}
|
|
13
|
+
*/
|
|
14
|
+
set sliceThickness(arg: number);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Gets the thickness of a slice created by a section.
|
|
18
|
+
*
|
|
19
|
+
* Default value is ````0.0````.
|
|
20
|
+
*
|
|
21
|
+
* @type {Number}
|
|
22
|
+
*/
|
|
23
|
+
get sliceThickness(): number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sets the color of a slice created by a section.
|
|
27
|
+
*
|
|
28
|
+
* Default value is ````[0.0, 0.0, 0.0, 1.0]````.
|
|
29
|
+
*
|
|
30
|
+
* @type {Number}
|
|
31
|
+
*/
|
|
32
|
+
set sliceColor(arg: number[]);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Gets the color of a slice created by a section.
|
|
36
|
+
*
|
|
37
|
+
* Default value is ````[0.0, 0.0, 0.0, 1.0]````.
|
|
38
|
+
*
|
|
39
|
+
* @type {Number}
|
|
40
|
+
*/
|
|
41
|
+
get sliceColor(): number[];
|
|
42
|
+
}
|