@woosh/meep-engine 2.34.35 → 2.34.39
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/core/binary/BitSet.js +5 -0
- package/core/bvh2/BinaryNode.js +873 -1017
- package/core/bvh2/LeafNode.js +82 -75
- package/core/bvh2/Node.js +112 -114
- package/core/bvh2/aabb3/AABB3.js +46 -1
- package/core/bvh2/aabb3/AABB3.spec.js +27 -1
- package/core/bvh2/aabb3/aabb3_from_v3_array.js +34 -0
- package/core/bvh2/aabb3/aabb3_from_v3_array_transformed.js +39 -0
- package/core/bvh2/aabb3/aabb3_intersects_frustum_degree.js +46 -0
- package/core/bvh2/traversal/ThreeFrustumsIntersectionBVHVisitor.js +16 -35
- package/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +52 -0
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +1 -1
- package/core/geom/3d/aabb/aabb3_matrix4_project.js +3 -4
- package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +13 -0
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -2
- package/core/geom/Quaternion.d.ts +2 -0
- package/core/geom/Vector3.js +22 -11
- package/engine/ecs/attachment/TransformAttachmentBinding.js +0 -1
- package/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +1 -31
- package/engine/ecs/foliage/InstancedFoliage.js +85 -152
- package/engine/ecs/foliage/ViewState.js +165 -0
- package/engine/ecs/foliage/ecs/Foliage2System.js +82 -19
- package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +30 -0
- package/engine/ecs/foliage/ecs/InstancedMeshLayer.js +16 -0
- package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +2 -2
- package/engine/ecs/parent/EntityNode.js +31 -49
- package/engine/ecs/transform-attachment/TransformAttachment.js +88 -0
- package/engine/ecs/transform-attachment/TransformAttachmentSystem.js +59 -0
- package/engine/graphics/GraphicsEngine.js +23 -2
- package/engine/graphics/ecs/camera/Camera.js +33 -16
- package/engine/graphics/ecs/camera/unprojectPoint.js +14 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +22 -17
- package/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +21 -21
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +9 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +4 -1
- package/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +32 -8
- package/engine/graphics/ecs/water2/shader/AlexWaterShader.js +7 -1
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +18 -12
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +1 -34
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +12 -0
- package/engine/graphics/micron/format/MicronGeometry.js +21 -0
- package/engine/graphics/micron/format/MicronGeometryPatch.js +0 -7
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +0 -3
- package/engine/graphics/micron/prototypeVirtualGeometry.js +69 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +5 -1
- package/engine/graphics/render/layers/RenderLayer.js +22 -85
- package/engine/graphics/render/visibility/VisibilityComputer.js +23 -103
- package/package.json +1 -1
- package/samples/terrain/editor.js +0 -1
|
@@ -26,7 +26,6 @@ import EmptyView from "../../view/elements/EmptyView.js";
|
|
|
26
26
|
import { assert } from "../../core/assert.js";
|
|
27
27
|
import { RenderLayerManager } from "./render/layers/RenderLayerManager.js";
|
|
28
28
|
import { FrameBufferManager } from "./render/buffer/FrameBufferManager.js";
|
|
29
|
-
import { SOURCE_RENDER_LAYER_PROPERTY } from "./render/visibility/VisibilityComputer.js";
|
|
30
29
|
import { ColorAndDepthFrameBuffer } from "./render/buffer/buffers/ColorAndDepthFrameBuffer.js";
|
|
31
30
|
import { RenderPassType } from "./render/RenderPassType.js";
|
|
32
31
|
import { renderTextureToScreenQuad } from "./render/utils/renderTextureToScreenQuad.js";
|
|
@@ -527,6 +526,26 @@ GraphicsEngine.prototype.clearVisibleGroup = function () {
|
|
|
527
526
|
this.visibleGroup.children.length = 0;
|
|
528
527
|
};
|
|
529
528
|
|
|
529
|
+
/**
|
|
530
|
+
*
|
|
531
|
+
* @param {THREE.Object3D} object
|
|
532
|
+
* @returns {RenderPassType}
|
|
533
|
+
*/
|
|
534
|
+
function classifyPassTypeFromObject(object) {
|
|
535
|
+
if (object.isMesh || object.isPoints) {
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* @type {THREE.Material}
|
|
539
|
+
*/
|
|
540
|
+
const material = object.material;
|
|
541
|
+
if (material.depthWrite === false && material.depthTest === false) {
|
|
542
|
+
return RenderPassType.Transparent;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return RenderPassType.Opaque;
|
|
547
|
+
}
|
|
548
|
+
|
|
530
549
|
/**
|
|
531
550
|
*
|
|
532
551
|
* @param {RenderPassType} passType
|
|
@@ -545,7 +564,9 @@ GraphicsEngine.prototype.prepareRenderPass = function (passType) {
|
|
|
545
564
|
for (let i = 0; i < element_count; i++) {
|
|
546
565
|
const object3D = visible_objects.elements[i];
|
|
547
566
|
|
|
548
|
-
|
|
567
|
+
const object_pass = classifyPassTypeFromObject(object3D);
|
|
568
|
+
|
|
569
|
+
if (object_pass === passType) {
|
|
549
570
|
|
|
550
571
|
//insert object, bypassing Object#add for speed
|
|
551
572
|
//visibleGroup.add(object3D);
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
|
|
7
7
|
import ObservedEnum from "../../../../core/model/ObservedEnum.js";
|
|
8
|
-
import {Frustum
|
|
9
|
-
import {assert} from "../../../../core/assert.js";
|
|
8
|
+
import { Frustum } from 'three';
|
|
9
|
+
import { assert } from "../../../../core/assert.js";
|
|
10
10
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
11
|
-
import {frustumFromCamera} from "./CameraSystem.js";
|
|
12
|
-
import {computePointDistanceToPlane} from "../../../../core/geom/Plane.js";
|
|
11
|
+
import { frustumFromCamera } from "./CameraSystem.js";
|
|
12
|
+
import { computePointDistanceToPlane } from "../../../../core/geom/Plane.js";
|
|
13
|
+
import { unprojectPoint } from "./unprojectPoint.js";
|
|
14
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
@@ -116,15 +118,15 @@ export class Camera {
|
|
|
116
118
|
|
|
117
119
|
/**
|
|
118
120
|
*
|
|
119
|
-
* @param {Camera} camera
|
|
121
|
+
* @param {Camera|THREE.PerspectiveCamera|THREE.OrthographicCamera} camera
|
|
120
122
|
* @param {number} x
|
|
121
123
|
* @param {number} y
|
|
122
124
|
* @param {Vector3} source
|
|
123
125
|
* @param {Vector3} direction
|
|
124
126
|
*/
|
|
125
127
|
static projectRay(camera, x, y, source, direction) {
|
|
126
|
-
assert.
|
|
127
|
-
assert.
|
|
128
|
+
assert.defined(camera, "camera");
|
|
129
|
+
assert.defined(camera.position, "Camera.position");
|
|
128
130
|
|
|
129
131
|
|
|
130
132
|
assert.isNumber(x, 'x');
|
|
@@ -136,18 +138,32 @@ export class Camera {
|
|
|
136
138
|
// assert.ok(y >= -1, `Y(=${y}) must be greater than or equal to -1.0, not a clip-space coordinate`);
|
|
137
139
|
// assert.ok(y <= 1, `Y(=${y}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
138
140
|
|
|
139
|
-
|
|
141
|
+
if (camera.isPerspectiveCamera) {
|
|
142
|
+
scratch_v3_1.setFromMatrixPosition(camera.matrixWorld.elements);
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
scratch_v3_0.set(x, y, 0.5);
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
// NOTE: projection inverse and world matrices are used in "unproject" operation, we update those to make things work as intended. This is handled by the camera system
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
unprojectPoint(
|
|
149
|
+
scratch_v3_0,
|
|
150
|
+
scratch_v3_0,
|
|
151
|
+
camera.projectionMatrixInverse.elements,
|
|
152
|
+
camera.matrixWorld.elements
|
|
153
|
+
);
|
|
146
154
|
|
|
147
|
-
|
|
148
|
-
|
|
155
|
+
//get direction
|
|
156
|
+
scratch_v3_0.sub(scratch_v3_1);
|
|
157
|
+
scratch_v3_0.normalize();
|
|
149
158
|
|
|
150
|
-
|
|
159
|
+
source.copy(scratch_v3_1);
|
|
160
|
+
direction.copy(scratch_v3_0);
|
|
161
|
+
|
|
162
|
+
} else if (camera.isOrthographicCamera) {
|
|
163
|
+
throw new Error('Unsupported camera type: "Orthographic" ');
|
|
164
|
+
} else {
|
|
165
|
+
throw new Error('Unsupported camera type');
|
|
166
|
+
}
|
|
151
167
|
}
|
|
152
168
|
|
|
153
169
|
/**
|
|
@@ -179,7 +195,7 @@ export class Camera {
|
|
|
179
195
|
|
|
180
196
|
const near = scratch_frustum.planes[0];
|
|
181
197
|
|
|
182
|
-
|
|
198
|
+
scratch_v3_0.set(x, y, z);
|
|
183
199
|
|
|
184
200
|
const normal = near.normal;
|
|
185
201
|
|
|
@@ -199,7 +215,8 @@ Camera.typeName = "Camera";
|
|
|
199
215
|
|
|
200
216
|
Camera.ProjectionType = ProjectionType;
|
|
201
217
|
|
|
202
|
-
const
|
|
218
|
+
const scratch_v3_0 = new Vector3();
|
|
219
|
+
const scratch_v3_1 = new Vector3();
|
|
203
220
|
const scratch_frustum = new Frustum();
|
|
204
221
|
|
|
205
222
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Vector3} result
|
|
6
|
+
* @param {Vector3} input
|
|
7
|
+
* @param {number[]} projection_matrix_inverse inverse of projection matrix
|
|
8
|
+
* @param {number[]} world_matrix world transform
|
|
9
|
+
*/
|
|
10
|
+
export function unprojectPoint(result, input, projection_matrix_inverse, world_matrix) {
|
|
11
|
+
result.copy(input);
|
|
12
|
+
result.applyMatrix4(projection_matrix_inverse);
|
|
13
|
+
result.applyMatrix4(world_matrix);
|
|
14
|
+
}
|
|
@@ -6,8 +6,6 @@ import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";
|
|
|
6
6
|
import { ShadowMap } from "../../shadow/ShadowMap.js";
|
|
7
7
|
import { CameraView } from "../../../../render/view/CameraView.js";
|
|
8
8
|
import { DoubleSide, Mesh, MeshDepthMaterial, RGBADepthPacking, Scene } from "three";
|
|
9
|
-
import { SOURCE_RENDER_LAYER_PROPERTY } from "../../../../render/visibility/VisibilityComputer.js";
|
|
10
|
-
import { RenderPassType } from "../../../../render/RenderPassType.js";
|
|
11
9
|
import { ThreeBypassRenderer } from "../../../../render/utils/ThreeBypassRenderer.js";
|
|
12
10
|
|
|
13
11
|
const shadow_scene = new Scene();
|
|
@@ -27,7 +25,8 @@ const __depth_material = new MeshDepthMaterial({
|
|
|
27
25
|
* @private
|
|
28
26
|
*/
|
|
29
27
|
function __getDepthMaterial(object) {
|
|
30
|
-
let result
|
|
28
|
+
let result;
|
|
29
|
+
|
|
31
30
|
const customDepthMaterial = object.customDepthMaterial;
|
|
32
31
|
|
|
33
32
|
if (customDepthMaterial !== undefined) {
|
|
@@ -44,24 +43,31 @@ function __getDepthMaterial(object) {
|
|
|
44
43
|
* @param {THREE.Object3D} object3D
|
|
45
44
|
* @return {boolean}
|
|
46
45
|
*/
|
|
47
|
-
function
|
|
48
|
-
const layer = object3D[SOURCE_RENDER_LAYER_PROPERTY];
|
|
46
|
+
function scene_object_filter(object3D) {
|
|
49
47
|
|
|
50
|
-
if (
|
|
48
|
+
if (object3D.castShadow === false) {
|
|
51
49
|
return false;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (object3D.visible === false) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
&&
|
|
56
|
+
if (object3D.isMesh) {
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @type {THREE.Material|null|undefined}
|
|
60
|
+
*/
|
|
61
|
+
const material = (object3D.customDepthMaterial !== null ? object3D.customDepthMaterial : object3D.material);
|
|
62
|
+
|
|
63
|
+
if (material && material.visible === false) {
|
|
64
|
+
//material's main
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return true;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
export class ThreeLightBinding extends LightBinding {
|
|
@@ -261,7 +267,6 @@ export class ThreeLightBinding extends LightBinding {
|
|
|
261
267
|
input: visible_objects.elements,
|
|
262
268
|
input_size: visible_object_count,
|
|
263
269
|
material_extractor: __getDepthMaterial,
|
|
264
|
-
input_filter: scene_input_filter,
|
|
265
270
|
object_filter: scene_object_filter
|
|
266
271
|
})
|
|
267
272
|
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { aabb3_matrix4_project_by_corners } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js";
|
|
1
|
+
import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
3
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Common buffer for scratch objects for better cache locality
|
|
5
|
+
* @type {ArrayBuffer}
|
|
6
|
+
*/
|
|
7
|
+
const scratch_buffer = new ArrayBuffer(28 * 4);
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {Float32Array}
|
|
12
|
+
*/
|
|
13
|
+
const scratch_matrix4 = new Float32Array(scratch_buffer, 0, 16);
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @type {Float64Array}
|
|
16
|
+
*
|
|
17
|
+
* @type {Float32Array}
|
|
11
18
|
*/
|
|
12
|
-
const
|
|
19
|
+
const scratch_aabb_0 = new Float32Array(scratch_buffer, 64, 6);
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
*
|
|
16
23
|
* @type {Float32Array}
|
|
17
24
|
*/
|
|
18
|
-
const
|
|
25
|
+
const scratch_aabb_1 = new Float32Array(scratch_buffer, 88, 6);
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
28
|
*
|
|
@@ -24,30 +31,23 @@ const scratch_aabb = new Float32Array(6);
|
|
|
24
31
|
* @param {Transform} transform
|
|
25
32
|
*/
|
|
26
33
|
export function updateNodeByTransformAndBBB(bvh, boundingBox, transform) {
|
|
27
|
-
transform.
|
|
34
|
+
transform.toMatrix4(scratch_matrix4);
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
* Shortcut elements for faster access
|
|
31
|
-
* @type {number[]}
|
|
32
|
-
*/
|
|
33
|
-
const e = matrix4.elements;
|
|
34
|
-
|
|
35
|
-
updateNodeByMatrix4AndBBB(bvh, boundingBox, e);
|
|
36
|
+
updateNodeByMatrix4AndBBB(bvh, boundingBox, scratch_matrix4);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
*
|
|
40
41
|
* @param {LeafNode} bvh
|
|
41
42
|
* @param {AABB3} boundingBox
|
|
42
|
-
* @param {number[]} matrix4
|
|
43
|
+
* @param {ArrayLike<number>|number[]|Float32Array} matrix4
|
|
43
44
|
*/
|
|
44
45
|
export function updateNodeByMatrix4AndBBB(bvh, boundingBox, matrix4) {
|
|
45
|
-
boundingBox.
|
|
46
|
-
|
|
46
|
+
boundingBox.writeToArray(scratch_aabb_1, 0);
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
aabb3_matrix4_project(scratch_aabb_0, scratch_aabb_1, matrix4);
|
|
49
49
|
|
|
50
|
-
bvh.readFromArray(
|
|
50
|
+
bvh.readFromArray(scratch_aabb_0, 0);
|
|
51
51
|
|
|
52
52
|
bvh.bubbleRefit();
|
|
53
53
|
}
|
|
@@ -4,9 +4,14 @@ import { LeafNode } from "../../../../core/bvh2/LeafNode.js";
|
|
|
4
4
|
import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
|
|
5
5
|
import { DrawMode } from "./DrawMode.js";
|
|
6
6
|
import { applyTransformToThreeObject } from "../mesh/applyTransformToThreeObject.js";
|
|
7
|
+
import { ShadedGeometryFlags } from "./ShadedGeometryFlags.js";
|
|
7
8
|
|
|
8
9
|
const _aabb3 = new AABB3();
|
|
9
10
|
|
|
11
|
+
const DEFAULT_FLAGS = ShadedGeometryFlags.CastShadow
|
|
12
|
+
| ShadedGeometryFlags.ReceiveShadow
|
|
13
|
+
;
|
|
14
|
+
|
|
10
15
|
export class ShadedGeometry {
|
|
11
16
|
constructor() {
|
|
12
17
|
/**
|
|
@@ -58,7 +63,7 @@ export class ShadedGeometry {
|
|
|
58
63
|
*
|
|
59
64
|
* @type {number}
|
|
60
65
|
*/
|
|
61
|
-
this.flags =
|
|
66
|
+
this.flags = DEFAULT_FLAGS;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/**
|
|
@@ -147,6 +152,9 @@ export class ShadedGeometry {
|
|
|
147
152
|
object.matrixAutoUpdate = false;
|
|
148
153
|
object.frustumCulled = false;
|
|
149
154
|
|
|
155
|
+
object.castShadow = this.getFlag(ShadedGeometryFlags.CastShadow);
|
|
156
|
+
object.receiveShadow = this.getFlag(ShadedGeometryFlags.ReceiveShadow);
|
|
157
|
+
|
|
150
158
|
this.__cached_object = object;
|
|
151
159
|
}
|
|
152
160
|
|
|
@@ -5,6 +5,7 @@ import { EngineConfiguration } from "../../../../EngineConfiguration.js";
|
|
|
5
5
|
import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
6
6
|
import { three_object_to_entity_composition } from "../three_object_to_entity_composition.js";
|
|
7
7
|
import { AttachmentSystem } from "../../../../ecs/attachment/AttachmentSystem.js";
|
|
8
|
+
import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/TransformAttachmentSystem.js";
|
|
8
9
|
|
|
9
10
|
const eh = new EngineHarness();
|
|
10
11
|
|
|
@@ -20,6 +21,7 @@ async function init(harness) {
|
|
|
20
21
|
|
|
21
22
|
config.addSystem(new ShadedGeometrySystem(engine));
|
|
22
23
|
config.addSystem(new AttachmentSystem());
|
|
24
|
+
config.addSystem(new TransformAttachmentSystem());
|
|
23
25
|
config.addLoader(GameAssetType.ModelGLTF_JSON, new GLTFAssetLoader());
|
|
24
26
|
|
|
25
27
|
await config.apply(engine);
|
|
@@ -29,20 +31,15 @@ async function init(harness) {
|
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
*
|
|
34
|
+
* @param {string} path
|
|
32
35
|
* @param {Engine} engine
|
|
33
36
|
*/
|
|
34
|
-
async function
|
|
35
|
-
|
|
37
|
+
async function load_gltf(path, engine) {
|
|
36
38
|
const em = engine.entityManager;
|
|
37
39
|
|
|
38
|
-
EngineHarness.buildBasics({
|
|
39
|
-
engine,
|
|
40
|
-
enableWater: false
|
|
41
|
-
})
|
|
42
|
-
|
|
43
40
|
const ecd = em.dataset;
|
|
44
41
|
|
|
45
|
-
const asset = await engine.assetManager.promise(
|
|
42
|
+
const asset = await engine.assetManager.promise(path, GameAssetType.ModelGLTF_JSON);
|
|
46
43
|
|
|
47
44
|
const three_object = asset.create();
|
|
48
45
|
|
|
@@ -57,4 +54,31 @@ async function main(engine) {
|
|
|
57
54
|
console.timeEnd('composition build');
|
|
58
55
|
}
|
|
59
56
|
|
|
57
|
+
async function timeout(t = 1) {
|
|
58
|
+
await new Promise((resolve, reject) => setTimeout(resolve, t));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {Engine} engine
|
|
64
|
+
*/
|
|
65
|
+
async function main(engine) {
|
|
66
|
+
|
|
67
|
+
EngineHarness.buildBasics({
|
|
68
|
+
engine,
|
|
69
|
+
enableWater: false,
|
|
70
|
+
enableTerrain: false
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// a small delay to let background tasks finish, so we can get better performance reading later on
|
|
74
|
+
timeout(20);
|
|
75
|
+
|
|
76
|
+
load_gltf('moicon/06_04_hapro/08-clickable-assets-new/model.gltf', engine);
|
|
77
|
+
// load_gltf('moicon/06_04_hapro/07-1st-basement/model.gltf', engine);
|
|
78
|
+
// load_gltf('moicon/06_04_hapro/06-lower-ground/model.gltf', engine);
|
|
79
|
+
// load_gltf('moicon/06_04_hapro/05-ground-floor/model.gltf', engine);
|
|
80
|
+
// load_gltf('moicon/06_04_hapro/04-1st-floor/model.gltf', engine);
|
|
81
|
+
// load_gltf('moicon/06_04_hapro/03-2nd-floor/model.gltf', engine);
|
|
82
|
+
}
|
|
83
|
+
|
|
60
84
|
init(eh);
|
|
@@ -228,7 +228,13 @@ export function makeAlexWaterMaterial() {
|
|
|
228
228
|
blending: NormalBlending,
|
|
229
229
|
lights: false,
|
|
230
230
|
fog: false,
|
|
231
|
-
|
|
231
|
+
|
|
232
|
+
/*
|
|
233
|
+
forcing transparent pass in Graphics Engine
|
|
234
|
+
three.js and indeed WebGL doesn't provide a way to pass depth buffer into the main draw pass (to canvas), so this is a workaround
|
|
235
|
+
*/
|
|
236
|
+
depthTest: false,
|
|
237
|
+
depthWrite: false,
|
|
232
238
|
transparent: true,
|
|
233
239
|
vertexColors: false
|
|
234
240
|
});
|
|
@@ -274,7 +274,7 @@ export class InstancedMeshGroup {
|
|
|
274
274
|
//get index
|
|
275
275
|
const index = this.count;
|
|
276
276
|
//grow
|
|
277
|
-
this.setCount(
|
|
277
|
+
this.setCount(index + 1);
|
|
278
278
|
|
|
279
279
|
this.indices[reference] = index;
|
|
280
280
|
this.references[index] = reference;
|
|
@@ -320,11 +320,13 @@ export class InstancedMeshGroup {
|
|
|
320
320
|
|
|
321
321
|
const lastIndex = this.count - 1;
|
|
322
322
|
|
|
323
|
+
const references = this.references;
|
|
324
|
+
|
|
323
325
|
if (index === lastIndex) {
|
|
324
326
|
//easy case, reference is placed at the end, no swap needed, we can just forget about it
|
|
325
|
-
delete
|
|
327
|
+
delete references[index];
|
|
326
328
|
} else {
|
|
327
|
-
//not at the end, move
|
|
329
|
+
//not at the end, move the very last reference to this place, effectively shrinking the set
|
|
328
330
|
const index3 = index * 3;
|
|
329
331
|
const start3 = lastIndex * 3;
|
|
330
332
|
const end3 = start3 + 3;
|
|
@@ -333,26 +335,30 @@ export class InstancedMeshGroup {
|
|
|
333
335
|
const start4 = lastIndex * 4;
|
|
334
336
|
const end4 = start4 + 4;
|
|
335
337
|
|
|
336
|
-
this.__attributePosition
|
|
337
|
-
this.__attributeRotation
|
|
338
|
-
this.__attributeScale
|
|
338
|
+
const a_position = this.__attributePosition;
|
|
339
|
+
const a_rotation = this.__attributeRotation;
|
|
340
|
+
const a_scale = this.__attributeScale;
|
|
341
|
+
|
|
342
|
+
a_position.array.copyWithin(index3, start3, end3);
|
|
343
|
+
a_rotation.array.copyWithin(index4, start4, end4);
|
|
344
|
+
a_scale.array.copyWithin(index3, start3, end3);
|
|
339
345
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
346
|
+
a_position.needsUpdate = true;
|
|
347
|
+
a_rotation.needsUpdate = true;
|
|
348
|
+
a_scale.needsUpdate = true;
|
|
343
349
|
|
|
344
350
|
//update moved reference index
|
|
345
|
-
const movedReference =
|
|
351
|
+
const movedReference = references[lastIndex];
|
|
346
352
|
|
|
347
353
|
if (movedReference === undefined) {
|
|
348
354
|
//moved reference not found
|
|
349
355
|
throw new Error(`Moved reference was not found`);
|
|
350
356
|
}
|
|
351
357
|
|
|
352
|
-
delete
|
|
358
|
+
delete references[lastIndex];
|
|
353
359
|
|
|
354
360
|
//assume the place of removed reference
|
|
355
|
-
|
|
361
|
+
references[index] = movedReference;
|
|
356
362
|
this.indices[movedReference] = index;
|
|
357
363
|
}
|
|
358
364
|
|
|
@@ -14,8 +14,7 @@ import { build_leaf_patches_metis } from "./clustering/build_leaf_patches_metis.
|
|
|
14
14
|
import { compute_buffer_geometry_byte_size } from "../../geometry/buffered/compute_buffer_geometry_byte_size.js";
|
|
15
15
|
import { deinterleaveBufferGeometry } from "../../geometry/buffered/deinterleaveBufferGeometry.js";
|
|
16
16
|
import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
|
|
17
|
-
import {
|
|
18
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
17
|
+
import { aabb3_from_v3_array } from "../../../../core/bvh2/aabb3/aabb3_from_v3_array.js";
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Returns current time in milliseconds
|
|
@@ -118,38 +117,6 @@ function attributes_from_buffer_geometry(buffer_geometry) {
|
|
|
118
117
|
|
|
119
118
|
const PRINT_VERBOSE_STATS = false;
|
|
120
119
|
|
|
121
|
-
/**
|
|
122
|
-
*
|
|
123
|
-
* @param {AABB3} result
|
|
124
|
-
* @param {number[]|ArrayLike<number>} input
|
|
125
|
-
* @param {number} input_length
|
|
126
|
-
*/
|
|
127
|
-
function aabb3_from_v3_array(result, input, input_length) {
|
|
128
|
-
let x0 = Infinity;
|
|
129
|
-
let y0 = Infinity;
|
|
130
|
-
let z0 = Infinity;
|
|
131
|
-
|
|
132
|
-
let x1 = -Infinity;
|
|
133
|
-
let y1 = -Infinity;
|
|
134
|
-
let z1 = -Infinity;
|
|
135
|
-
|
|
136
|
-
for (let i = 0; i < input_length; i += 3) {
|
|
137
|
-
const x = input[i];
|
|
138
|
-
const y = input[i + 1];
|
|
139
|
-
const z = input[i + 2];
|
|
140
|
-
|
|
141
|
-
x0 = min2(x, x0);
|
|
142
|
-
y0 = min2(y, y0);
|
|
143
|
-
z0 = min2(z, z0);
|
|
144
|
-
|
|
145
|
-
x1 = max2(x, x1);
|
|
146
|
-
y1 = max2(y, y1);
|
|
147
|
-
z1 = max2(z, z1);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
result.setBounds(x0, y0, z0, x1, y1, z1);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
120
|
/**
|
|
154
121
|
*
|
|
155
122
|
* @param {THREE.BufferGeometry} input
|
|
@@ -113,6 +113,15 @@ function normalize_to_int8(value) {
|
|
|
113
113
|
return Math.round(value * 127);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @param {number} value
|
|
119
|
+
* @return {number}
|
|
120
|
+
*/
|
|
121
|
+
function normalize_to_uint8(value) {
|
|
122
|
+
return Math.round(value * 255);
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
/**
|
|
117
126
|
* @enum {function(number):number}
|
|
118
127
|
*/
|
|
@@ -120,6 +129,7 @@ const DataConverterType = {
|
|
|
120
129
|
None: passThrough,
|
|
121
130
|
Number2HalfFloat: to_half_float_uint16,
|
|
122
131
|
Normalize2Int8: normalize_to_int8,
|
|
132
|
+
Normalize2Uint8: normalize_to_uint8,
|
|
123
133
|
ResampleNormalized_Uint16_to_Uint8: resample_normalized_uint16_to_uint8
|
|
124
134
|
};
|
|
125
135
|
|
|
@@ -137,6 +147,8 @@ function compute_attribute_data_converter(source, spec) {
|
|
|
137
147
|
// source data can be normalized but isn't
|
|
138
148
|
if (target_type === DataType.Int8) {
|
|
139
149
|
return DataConverterType.Normalize2Int8;
|
|
150
|
+
} else if (target_type === DataType.Uint8) {
|
|
151
|
+
return DataConverterType.Normalize2Uint8;
|
|
140
152
|
} else {
|
|
141
153
|
throw new Error(`Unsupported normalized type '${target_type}'`);
|
|
142
154
|
}
|
|
@@ -4,6 +4,7 @@ import { computeTriangleRayIntersection } from "../../../../core/geom/3d/triangl
|
|
|
4
4
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
5
5
|
import { aabb3_array_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_array_intersects_ray.js";
|
|
6
6
|
import { sphere_array_intersects_ray } from "../../../../core/geom/3d/sphere/sphere_array_intersects_ray.js";
|
|
7
|
+
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
7
8
|
|
|
8
9
|
let id_counter = 0;
|
|
9
10
|
|
|
@@ -13,6 +14,13 @@ let id_counter = 0;
|
|
|
13
14
|
*/
|
|
14
15
|
const scratch_traversal_stack = [];
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {BitSet}
|
|
20
|
+
*/
|
|
21
|
+
const scratch_traversal_bitset = new BitSet();
|
|
22
|
+
scratch_traversal_bitset.preventShrink();
|
|
23
|
+
|
|
16
24
|
export class MicronGeometry {
|
|
17
25
|
constructor() {
|
|
18
26
|
/**
|
|
@@ -79,6 +87,7 @@ export class MicronGeometry {
|
|
|
79
87
|
origin_x, origin_y, origin_z,
|
|
80
88
|
direction_x, direction_y, direction_z
|
|
81
89
|
) {
|
|
90
|
+
|
|
82
91
|
let i;
|
|
83
92
|
let stack_cursor = 1;
|
|
84
93
|
|
|
@@ -99,6 +108,11 @@ export class MicronGeometry {
|
|
|
99
108
|
// check that position attribute actually exists
|
|
100
109
|
assert.isNonNegativeInteger(position_attribute_index, 'position_attribute_index');
|
|
101
110
|
|
|
111
|
+
const included_set = scratch_traversal_bitset;
|
|
112
|
+
included_set.reset();
|
|
113
|
+
|
|
114
|
+
included_set.set(this.root.id, true);
|
|
115
|
+
|
|
102
116
|
const temp_hit = new SurfacePoint3();
|
|
103
117
|
|
|
104
118
|
while (stack_cursor > 0) {
|
|
@@ -106,6 +120,7 @@ export class MicronGeometry {
|
|
|
106
120
|
|
|
107
121
|
const patch = stack[stack_cursor];
|
|
108
122
|
|
|
123
|
+
|
|
109
124
|
if (patch.lod === 0) {
|
|
110
125
|
// LOD 0 - source geometry
|
|
111
126
|
|
|
@@ -206,9 +221,15 @@ export class MicronGeometry {
|
|
|
206
221
|
for (i = 0; i < child_count; i++) {
|
|
207
222
|
const child = children[i];
|
|
208
223
|
|
|
224
|
+
if (included_set.get(child.id)) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
|
|
209
228
|
// push to stack
|
|
210
229
|
stack[stack_cursor] = child;
|
|
211
230
|
|
|
231
|
+
included_set.set(child.id, true);
|
|
232
|
+
|
|
212
233
|
stack_cursor++;
|
|
213
234
|
}
|
|
214
235
|
}
|
|
@@ -68,13 +68,6 @@ export class MicronGeometryPatch {
|
|
|
68
68
|
*/
|
|
69
69
|
this.children = [];
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Runtime dependency patches, if this patch is refined at runtime - dependencies must be refined as well
|
|
73
|
-
* These dependencies allow for more aggressive simplification of topology
|
|
74
|
-
* @type {number[]}
|
|
75
|
-
*/
|
|
76
|
-
this.dependencies = [];
|
|
77
|
-
|
|
78
71
|
/**
|
|
79
72
|
* Level of detail, lower number means more detailed
|
|
80
73
|
* @type {number}
|
|
@@ -2,7 +2,6 @@ import { EnginePlugin } from "../../../plugin/EnginePlugin.js";
|
|
|
2
2
|
import { VGThreeRenderer } from "../render/v1/VGThreeRenderer.js";
|
|
3
3
|
import { RenderLayer } from "../../render/layers/RenderLayer.js";
|
|
4
4
|
import { RenderPassType } from "../../render/RenderPassType.js";
|
|
5
|
-
import { SOURCE_RENDER_LAYER_PROPERTY } from "../../render/visibility/VisibilityComputer.js";
|
|
6
5
|
import { AssetTransformer } from "../../../asset/AssetTransformer.js";
|
|
7
6
|
import { convert_three_object_to_micron } from "../convert_three_object_to_micron.js";
|
|
8
7
|
import { Cache } from "../../../../core/cache/Cache.js";
|
|
@@ -180,8 +179,6 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
180
179
|
|
|
181
180
|
const mesh = ctx.mesh;
|
|
182
181
|
|
|
183
|
-
mesh[SOURCE_RENDER_LAYER_PROPERTY] = layer;
|
|
184
|
-
|
|
185
182
|
visibleSet.elements.push(mesh);
|
|
186
183
|
visibleSet.size++;
|
|
187
184
|
|