@xeokit/xeokit-sdk 2.4.2-beta-21 → 2.4.2-beta-23
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 +750 -598
- package/dist/xeokit-sdk.es.js +750 -598
- package/dist/xeokit-sdk.es5.js +227 -198
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +4 -4
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/viewer/Viewer.js +7 -1
- package/src/viewer/scene/mesh/draw/DrawRenderer.js +18 -8
- package/src/viewer/scene/mesh/draw/DrawShaderSource.js +8 -8
- package/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +19 -9
- package/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +3 -3
- package/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +19 -9
- package/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +3 -3
- package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +18 -8
- package/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +3 -3
- package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +18 -8
- package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +3 -3
- package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +18 -8
- package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +3 -3
- package/src/viewer/scene/mesh/shadow/ShadowRenderer.js +1 -1
- package/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +3 -3
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureColorRenderer.js +22 -17
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureDepthRenderer.js +22 -21
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +7 -10
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +22 -19
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureNormalsRenderer.js +22 -18
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureOcclusionRenderer.js +22 -17
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickDepthRenderer.js +22 -18
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js +59 -55
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +22 -20
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +22 -18
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js +22 -19
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +22 -19
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +22 -19
- package/src/viewer/scene/model/vbo/VBOSceneModelRenderers.js +21 -16
- package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthBufInitRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthBufInitRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorTextureRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingFlatColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPBRRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsFlatRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorTextureRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatColorRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPBRRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsFlatRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +4 -4
- package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +4 -4
- package/src/viewer/scene/scene/Scene.js +57 -11
- package/src/viewer/scene/sectionPlane/SectionPlaneCache.js +101 -0
|
@@ -7,7 +7,7 @@ class TrianglesInstancingPickDepthRenderer extends VBOSceneModelTriangleInstanci
|
|
|
7
7
|
_buildVertexShader() {
|
|
8
8
|
const scene = this._scene;
|
|
9
9
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
10
|
-
const clipping = sectionPlanesState.
|
|
10
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
11
11
|
const src = [];
|
|
12
12
|
src.push("#version 300 es");
|
|
13
13
|
src.push("// Instancing geometry depth vertex shader");
|
|
@@ -83,7 +83,7 @@ class TrianglesInstancingPickDepthRenderer extends VBOSceneModelTriangleInstanci
|
|
|
83
83
|
_buildFragmentShader() {
|
|
84
84
|
const scene = this._scene;
|
|
85
85
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
86
|
-
const clipping = sectionPlanesState.
|
|
86
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
87
87
|
const src = [];
|
|
88
88
|
src.push("#version 300 es");
|
|
89
89
|
src.push("// Batched geometry depth fragment shader");
|
|
@@ -109,7 +109,7 @@ class TrianglesInstancingPickDepthRenderer extends VBOSceneModelTriangleInstanci
|
|
|
109
109
|
if (clipping) {
|
|
110
110
|
src.push("in vec4 vWorldPosition;");
|
|
111
111
|
src.push("in float vFlags;");
|
|
112
|
-
for (let i = 0; i < sectionPlanesState.
|
|
112
|
+
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
113
113
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
114
114
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
115
115
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -129,7 +129,7 @@ class TrianglesInstancingPickDepthRenderer extends VBOSceneModelTriangleInstanci
|
|
|
129
129
|
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
130
130
|
src.push(" if (clippable) {");
|
|
131
131
|
src.push(" float dist = 0.0;");
|
|
132
|
-
for (let i = 0; i < sectionPlanesState.
|
|
132
|
+
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
133
133
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
134
134
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
135
135
|
src.push("}");
|
|
@@ -8,7 +8,7 @@ class TrianglesInstancingPickMeshRenderer extends VBOSceneModelTriangleInstancin
|
|
|
8
8
|
_buildVertexShader() {
|
|
9
9
|
const scene = this._scene;
|
|
10
10
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
11
|
-
const clipping = sectionPlanesState.
|
|
11
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
12
12
|
const src = [];
|
|
13
13
|
src.push("#version 300 es");
|
|
14
14
|
src.push("// Instancing geometry picking vertex shader");
|
|
@@ -84,7 +84,7 @@ class TrianglesInstancingPickMeshRenderer extends VBOSceneModelTriangleInstancin
|
|
|
84
84
|
_buildFragmentShader() {
|
|
85
85
|
const scene = this._scene;
|
|
86
86
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
87
|
-
const clipping = sectionPlanesState.
|
|
87
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
88
88
|
const src = [];
|
|
89
89
|
src.push("#version 300 es");
|
|
90
90
|
src.push("// Batched geometry picking fragment shader");
|
|
@@ -104,7 +104,7 @@ class TrianglesInstancingPickMeshRenderer extends VBOSceneModelTriangleInstancin
|
|
|
104
104
|
if (clipping) {
|
|
105
105
|
src.push("in vec4 vWorldPosition;");
|
|
106
106
|
src.push("in float vFlags;");
|
|
107
|
-
for (let i = 0; i < sectionPlanesState.
|
|
107
|
+
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
108
108
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
109
109
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
110
110
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -117,7 +117,7 @@ class TrianglesInstancingPickMeshRenderer extends VBOSceneModelTriangleInstancin
|
|
|
117
117
|
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
118
118
|
src.push(" if (clippable) {");
|
|
119
119
|
src.push(" float dist = 0.0;");
|
|
120
|
-
for (let i = 0; i < sectionPlanesState.
|
|
120
|
+
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
121
121
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
122
122
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
123
123
|
src.push("}");
|
|
@@ -9,7 +9,7 @@ class TrianglesInstancingPickNormalsFlatRenderer extends VBOSceneModelTriangleIn
|
|
|
9
9
|
_buildVertexShader() {
|
|
10
10
|
const scene = this._scene;
|
|
11
11
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
12
|
-
const clipping = sectionPlanesState.
|
|
12
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
13
13
|
const src = [];
|
|
14
14
|
src.push("#version 300 es");
|
|
15
15
|
src.push("// Instancing geometry normals vertex shader");
|
|
@@ -76,7 +76,7 @@ class TrianglesInstancingPickNormalsFlatRenderer extends VBOSceneModelTriangleIn
|
|
|
76
76
|
_buildFragmentShader() {
|
|
77
77
|
const scene = this._scene;
|
|
78
78
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
79
|
-
const clipping = sectionPlanesState.
|
|
79
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
80
80
|
const src = [];
|
|
81
81
|
src.push("#version 300 es");
|
|
82
82
|
src.push("// Batched geometry normals fragment shader");
|
|
@@ -97,7 +97,7 @@ class TrianglesInstancingPickNormalsFlatRenderer extends VBOSceneModelTriangleIn
|
|
|
97
97
|
src.push("in vec4 vWorldPosition;");
|
|
98
98
|
if (clipping) {
|
|
99
99
|
src.push("in float vFlags;");
|
|
100
|
-
for (let i = 0; i < sectionPlanesState.
|
|
100
|
+
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
101
101
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
102
102
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
103
103
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -109,7 +109,7 @@ class TrianglesInstancingPickNormalsFlatRenderer extends VBOSceneModelTriangleIn
|
|
|
109
109
|
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
110
110
|
src.push(" if (clippable) {");
|
|
111
111
|
src.push(" float dist = 0.0;");
|
|
112
|
-
for (var i = 0; i < sectionPlanesState.
|
|
112
|
+
for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
113
113
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
114
114
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
115
115
|
src.push("}");
|
|
@@ -9,7 +9,7 @@ class TrianglesInstancingPickNormalsRenderer extends VBOSceneModelTriangleInstan
|
|
|
9
9
|
_buildVertexShader() {
|
|
10
10
|
const scene = this._scene;
|
|
11
11
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
12
|
-
const clipping = sectionPlanesState.
|
|
12
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
13
13
|
const src = [];
|
|
14
14
|
src.push("#version 300 es");
|
|
15
15
|
src.push("// Instancing geometry normals vertex shader");
|
|
@@ -90,7 +90,7 @@ class TrianglesInstancingPickNormalsRenderer extends VBOSceneModelTriangleInstan
|
|
|
90
90
|
_buildFragmentShader() {
|
|
91
91
|
const scene = this._scene;
|
|
92
92
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
93
|
-
const clipping = sectionPlanesState.
|
|
93
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
94
94
|
const src = [];
|
|
95
95
|
src.push("#version 300 es");
|
|
96
96
|
src.push("// Batched geometry normals fragment shader");
|
|
@@ -114,7 +114,7 @@ class TrianglesInstancingPickNormalsRenderer extends VBOSceneModelTriangleInstan
|
|
|
114
114
|
if (clipping) {
|
|
115
115
|
src.push("in vec4 vWorldPosition;");
|
|
116
116
|
src.push("in float vFlags;");
|
|
117
|
-
for (let i = 0; i < sectionPlanesState.
|
|
117
|
+
for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
118
118
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
119
119
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
120
120
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -127,7 +127,7 @@ class TrianglesInstancingPickNormalsRenderer extends VBOSceneModelTriangleInstan
|
|
|
127
127
|
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
128
128
|
src.push(" if (clippable) {");
|
|
129
129
|
src.push(" float dist = 0.0;");
|
|
130
|
-
for (var i = 0; i < sectionPlanesState.
|
|
130
|
+
for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
|
|
131
131
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
132
132
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
133
133
|
src.push("}");
|
|
@@ -9,7 +9,7 @@ class TrianglesInstancingShadowRenderer extends VBOSceneModelTriangleInstancingR
|
|
|
9
9
|
_buildVertexShader() {
|
|
10
10
|
const scene = this._scene;
|
|
11
11
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
12
|
-
const clipping = sectionPlanesState.
|
|
12
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
13
13
|
const src = [];
|
|
14
14
|
src.push("#version 300 es");
|
|
15
15
|
src.push("// Instancing geometry shadow drawing vertex shader");
|
|
@@ -58,7 +58,7 @@ class TrianglesInstancingShadowRenderer extends VBOSceneModelTriangleInstancingR
|
|
|
58
58
|
_buildFragmentShader() {
|
|
59
59
|
const scene = this._scene;
|
|
60
60
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
61
|
-
const clipping = sectionPlanesState.
|
|
61
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
62
62
|
const src = [];
|
|
63
63
|
src.push("#version 300 es");
|
|
64
64
|
src.push("// Instancing geometry depth drawing fragment shader");
|
|
@@ -77,7 +77,7 @@ class TrianglesInstancingShadowRenderer extends VBOSceneModelTriangleInstancingR
|
|
|
77
77
|
if (clipping) {
|
|
78
78
|
src.push("in vec4 vWorldPosition;");
|
|
79
79
|
src.push("in float vFlags;");
|
|
80
|
-
for (let i = 0, len = sectionPlanesState.
|
|
80
|
+
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
81
81
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
82
82
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
83
83
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -93,7 +93,7 @@ class TrianglesInstancingShadowRenderer extends VBOSceneModelTriangleInstancingR
|
|
|
93
93
|
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
94
94
|
src.push(" if (clippable) {");
|
|
95
95
|
src.push(" float dist = 0.0;");
|
|
96
|
-
for (let i = 0, len = sectionPlanesState.
|
|
96
|
+
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
97
97
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
98
98
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
99
99
|
src.push("}");
|
|
@@ -13,7 +13,7 @@ class TrianglesInstancingSilhouetteRenderer extends VBOSceneModelTriangleInstanc
|
|
|
13
13
|
_buildVertexShader() {
|
|
14
14
|
const scene = this._scene;
|
|
15
15
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
16
|
-
const clipping = sectionPlanesState.
|
|
16
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
17
17
|
const src = [];
|
|
18
18
|
src.push("#version 300 es");
|
|
19
19
|
src.push("// Instancing silhouette vertex shader");
|
|
@@ -88,7 +88,7 @@ class TrianglesInstancingSilhouetteRenderer extends VBOSceneModelTriangleInstanc
|
|
|
88
88
|
_buildFragmentShader() {
|
|
89
89
|
const scene = this._scene;
|
|
90
90
|
const sectionPlanesState = scene._sectionPlanesState;
|
|
91
|
-
const clipping = sectionPlanesState.
|
|
91
|
+
const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
|
|
92
92
|
const src = [];
|
|
93
93
|
src.push("#version 300 es");
|
|
94
94
|
src.push("// Instancing fill fragment shader");
|
|
@@ -108,7 +108,7 @@ class TrianglesInstancingSilhouetteRenderer extends VBOSceneModelTriangleInstanc
|
|
|
108
108
|
if (clipping) {
|
|
109
109
|
src.push("in vec4 vWorldPosition;");
|
|
110
110
|
src.push("in float vFlags;");
|
|
111
|
-
for (let i = 0, len = sectionPlanesState.
|
|
111
|
+
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
112
112
|
src.push("uniform bool sectionPlaneActive" + i + ";");
|
|
113
113
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
114
114
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
@@ -121,7 +121,7 @@ class TrianglesInstancingSilhouetteRenderer extends VBOSceneModelTriangleInstanc
|
|
|
121
121
|
src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
|
|
122
122
|
src.push(" if (clippable) {");
|
|
123
123
|
src.push(" float dist = 0.0;");
|
|
124
|
-
for (let i = 0, len = sectionPlanesState.
|
|
124
|
+
for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
|
|
125
125
|
src.push("if (sectionPlaneActive" + i + ") {");
|
|
126
126
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
127
127
|
src.push("}");
|
|
@@ -338,8 +338,13 @@ class Scene extends Component {
|
|
|
338
338
|
* @param {Viewer} viewer The Viewer this Scene belongs to.
|
|
339
339
|
* @param {Object} cfg Scene configuration.
|
|
340
340
|
* @param {String} [cfg.canvasId] ID of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasElement is mandatory. When both values are given, the element reference is always preferred to the ID.
|
|
341
|
-
|
|
341
|
+
* @param {HTMLCanvasElement} [cfg.canvasElement] Reference of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasId is mandatory. When both values are given, the element reference is always preferred to the ID.
|
|
342
342
|
* @param {HTMLElement} [cfg.keyboardEventsElement] Optional reference to HTML element on which key events should be handled. Defaults to the HTML Document.
|
|
343
|
+
* @param {number} [cfg.numCachedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
|
|
344
|
+
* of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
|
|
345
|
+
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
346
|
+
* 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
|
|
347
|
+
* your expected usage.
|
|
343
348
|
* @throws {String} Throws an exception when both canvasId or canvasElement are missing or they aren't pointing to a valid HTMLCanvasElement.
|
|
344
349
|
*/
|
|
345
350
|
constructor(viewer, cfg = {}) {
|
|
@@ -362,6 +367,8 @@ class Scene extends Component {
|
|
|
362
367
|
|
|
363
368
|
this._aabbDirty = true;
|
|
364
369
|
|
|
370
|
+
this._numCachedSectionPlanes = cfg.numCachedSectionPlanes || 0;
|
|
371
|
+
|
|
365
372
|
/**
|
|
366
373
|
* The {@link Viewer} this Scene belongs to.
|
|
367
374
|
* @type {Viewer}
|
|
@@ -624,6 +631,8 @@ class Scene extends Component {
|
|
|
624
631
|
alphaDepthMask: alphaDepthMask
|
|
625
632
|
});
|
|
626
633
|
|
|
634
|
+
const numCachedSectionPlanes = this._numCachedSectionPlanes;
|
|
635
|
+
|
|
627
636
|
this._sectionPlanesState = new (function () {
|
|
628
637
|
|
|
629
638
|
this.sectionPlanes = [];
|
|
@@ -636,14 +645,15 @@ class Scene extends Component {
|
|
|
636
645
|
if (hash) {
|
|
637
646
|
return hash;
|
|
638
647
|
}
|
|
648
|
+
const numAllocatedSectionPlanes = this.getNumAllocatedSectionPlanes();
|
|
639
649
|
const sectionPlanes = this.sectionPlanes;
|
|
640
|
-
if (
|
|
650
|
+
if (numAllocatedSectionPlanes === 0) {
|
|
641
651
|
return this.hash = ";";
|
|
642
652
|
}
|
|
643
653
|
let sectionPlane;
|
|
644
654
|
|
|
645
655
|
const hashParts = [];
|
|
646
|
-
for (let i = 0, len =
|
|
656
|
+
for (let i = 0, len = numAllocatedSectionPlanes; i < len; i++) {
|
|
647
657
|
sectionPlane = sectionPlanes[i];
|
|
648
658
|
hashParts.push("cp");
|
|
649
659
|
}
|
|
@@ -666,6 +676,11 @@ class Scene extends Component {
|
|
|
666
676
|
}
|
|
667
677
|
}
|
|
668
678
|
};
|
|
679
|
+
|
|
680
|
+
this.getNumAllocatedSectionPlanes = function () {
|
|
681
|
+
const num = this.sectionPlanes.length;
|
|
682
|
+
return (num > numCachedSectionPlanes) ? num : numCachedSectionPlanes;
|
|
683
|
+
};
|
|
669
684
|
})();
|
|
670
685
|
|
|
671
686
|
this._lightsState = new (function () {
|
|
@@ -1243,12 +1258,43 @@ class Scene extends Component {
|
|
|
1243
1258
|
return this._logarithmicDepthBufferEnabled;
|
|
1244
1259
|
}
|
|
1245
1260
|
|
|
1261
|
+
/**
|
|
1262
|
+
* Sets the number of {@link SectionPlane}s for which this Scene pre-caches resources.
|
|
1263
|
+
*
|
|
1264
|
+
* This property enhances the efficiency of SectionPlane creation by proactively allocating and caching Viewer resources for a specified quantity
|
|
1265
|
+
* of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
|
|
1266
|
+
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
1267
|
+
* responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
|
|
1268
|
+
* your expected usage.
|
|
1269
|
+
*
|
|
1270
|
+
* Default is ````0````.
|
|
1271
|
+
*/
|
|
1272
|
+
set numCachedSectionPlanes(numCachedSectionPlanes) {
|
|
1273
|
+
this._numCachedSectionPlanes = numCachedSectionPlanes;
|
|
1274
|
+
this._recompile();
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Gets the number of {@link SectionPlane}s for which this Scene pre-caches resources.
|
|
1279
|
+
*
|
|
1280
|
+
* This property enhances the efficiency of SectionPlane creation by proactively allocating and caching Viewer resources for a specified quantity
|
|
1281
|
+
* of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
|
|
1282
|
+
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
1283
|
+
* responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
|
|
1284
|
+
* your expected usage.
|
|
1285
|
+
*
|
|
1286
|
+
* Default is ````0````.
|
|
1287
|
+
*
|
|
1288
|
+
* @returns {number} The number of {@link SectionPlane}s for which this Scene pre-caches resources.
|
|
1289
|
+
*/
|
|
1290
|
+
get numCachedSectionPlanes() {
|
|
1291
|
+
return this._numCachedSectionPlanes;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1246
1294
|
/**
|
|
1247
1295
|
* Sets whether physically-based rendering is enabled.
|
|
1248
1296
|
*
|
|
1249
1297
|
* Default is ````false````.
|
|
1250
|
-
*
|
|
1251
|
-
* @returns {Boolean} True if quality rendering is enabled.
|
|
1252
1298
|
*/
|
|
1253
1299
|
set pbrEnabled(pbrEnabled) {
|
|
1254
1300
|
this._pbrEnabled = !!pbrEnabled;
|
|
@@ -2588,12 +2634,12 @@ class Scene extends Component {
|
|
|
2588
2634
|
|
|
2589
2635
|
/**
|
|
2590
2636
|
* This method will "tickify" the provided `cb` function.
|
|
2591
|
-
*
|
|
2637
|
+
*
|
|
2592
2638
|
* This means, the function will be wrapped so:
|
|
2593
|
-
*
|
|
2639
|
+
*
|
|
2594
2640
|
* - it runs time-aligned to scene ticks
|
|
2595
2641
|
* - it runs maximum once per scene-tick
|
|
2596
|
-
*
|
|
2642
|
+
*
|
|
2597
2643
|
* @param {Function} cb The function to tickify
|
|
2598
2644
|
* @returns {Function)}
|
|
2599
2645
|
*/
|
|
@@ -2614,7 +2660,7 @@ class Scene extends Component {
|
|
|
2614
2660
|
|
|
2615
2661
|
/**
|
|
2616
2662
|
* The provided `cb` function is replaced with a "set-dirty" function
|
|
2617
|
-
*
|
|
2663
|
+
*
|
|
2618
2664
|
* @type {Function}
|
|
2619
2665
|
*/
|
|
2620
2666
|
const wrapperFunc = function (...args) {
|
|
@@ -2624,7 +2670,7 @@ class Scene extends Component {
|
|
|
2624
2670
|
|
|
2625
2671
|
/**
|
|
2626
2672
|
* An each scene tick, if the "dirty-flag" is set, run the `cb` function.
|
|
2627
|
-
*
|
|
2673
|
+
*
|
|
2628
2674
|
* This will make it run time-aligned to the scene tick.
|
|
2629
2675
|
*/
|
|
2630
2676
|
const tickSubId = this.on("tick", () => {
|
|
@@ -2638,7 +2684,7 @@ class Scene extends Component {
|
|
|
2638
2684
|
/**
|
|
2639
2685
|
* And, store the list of subscribers.
|
|
2640
2686
|
*/
|
|
2641
|
-
this._tickifiedFunctions[cbString] = {
|
|
2687
|
+
this._tickifiedFunctions[cbString] = {tickSubId, wrapperFunc};
|
|
2642
2688
|
|
|
2643
2689
|
return wrapperFunc;
|
|
2644
2690
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {Component} from '../Component.js';
|
|
2
|
+
import {math} from "../math/math.js";
|
|
3
|
+
import {SectionPlane} from "./SectionPlane";
|
|
4
|
+
|
|
5
|
+
const tempVec3a = math.vec3();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @desc A set of arbitrarily-aligned World-space clipping planes.
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
export class SectionPlaneCache extends Component {
|
|
12
|
+
|
|
13
|
+
constructor(owner, cfg = {}) {
|
|
14
|
+
super(owner, cfg);
|
|
15
|
+
|
|
16
|
+
this._sectionPlanesMap = {};
|
|
17
|
+
this._sectionPlanesState = {};
|
|
18
|
+
|
|
19
|
+
if (cfg.size) {
|
|
20
|
+
for (let i = 0, len = cfg.size; i < len; i++) {
|
|
21
|
+
const sectionPlane = new SectionPlane(this.viewer.scene, {
|
|
22
|
+
id: math.createUUID(),
|
|
23
|
+
pos: [0, 0, 0],
|
|
24
|
+
dir: [0, -1, 0],
|
|
25
|
+
active: false
|
|
26
|
+
});
|
|
27
|
+
this._sectionPlanesMap[sectionPlane.id] = sectionPlane;
|
|
28
|
+
this._sectionPlanesState[sectionPlane.id] = {
|
|
29
|
+
sectionPlane: sectionPlane,
|
|
30
|
+
used: false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getSectionPlane(params = {}) {
|
|
37
|
+
for (let id in this._sectionPlanesState) {
|
|
38
|
+
const state = this._sectionPlanesState[id];
|
|
39
|
+
if (!state.used) {
|
|
40
|
+
state.used = true;
|
|
41
|
+
const sectionPlane = state.sectionPlane;
|
|
42
|
+
sectionPlane.active = true;
|
|
43
|
+
sectionPlane.pos = params.pos;
|
|
44
|
+
sectionPlane.dir = params.dir;
|
|
45
|
+
return sectionPlane;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const sectionPlane = new SectionPlane(this.viewer.scene, {
|
|
49
|
+
id: params.id, // Optional
|
|
50
|
+
pos: params.pos,
|
|
51
|
+
dir: params.dir,
|
|
52
|
+
active: true
|
|
53
|
+
});
|
|
54
|
+
this._sectionPlanesState[sectionPlane.id] = {
|
|
55
|
+
sectionPlane: sectionPlane,
|
|
56
|
+
used: true
|
|
57
|
+
};
|
|
58
|
+
return sectionPlane;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
putSectionPlane(sectionPlane) {
|
|
62
|
+
let state = this._sectionPlanesState[sectionPlane.id];
|
|
63
|
+
sectionPlane.active = false;
|
|
64
|
+
if (state) {
|
|
65
|
+
state.used = false;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this._sectionPlanesState[sectionPlane.id] = {
|
|
69
|
+
sectionPlane: sectionPlane,
|
|
70
|
+
used: false
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
putAllSectionPlanes() {
|
|
75
|
+
for (let id in this._sectionPlanesState) {
|
|
76
|
+
const state = this._sectionPlanesState[id];
|
|
77
|
+
state.used = false;
|
|
78
|
+
state.sectionPlane.active = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getSectionPlanesInUse() {
|
|
83
|
+
const sectionPlanes = [];
|
|
84
|
+
for (let id in this._sectionPlanesState) {
|
|
85
|
+
const state = this._sectionPlanesState[id];
|
|
86
|
+
if (state.used) {
|
|
87
|
+
sectionPlanes.push(state.sectionPlane);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return sectionPlanes;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @destroy
|
|
95
|
+
*/
|
|
96
|
+
destroy() {
|
|
97
|
+
this.scene._sectionPlaneDestroyed(this);
|
|
98
|
+
super.destroy();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|