@woosh/meep-engine 2.35.14 → 2.35.17
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/collection/array/typed/uint_array_for_count.js +17 -0
- package/core/geom/3d/ray/ray3_array_apply_matrix4.js +42 -0
- package/core/geom/3d/ray/ray3_array_compose.js +19 -0
- package/core/geom/3d/ray/ray3_array_compose.spec.js +14 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +18 -24
- package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +2 -3
- package/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +212 -0
- package/engine/graphics/ecs/path/PathDisplaySystem.js +2 -1
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +8 -8
- package/engine/graphics/ecs/path/tube/CapType.d.ts +5 -0
- package/engine/graphics/ecs/path/tube/CapType.js +9 -0
- package/engine/graphics/ecs/path/tube/TubePathStyle.d.ts +2 -0
- package/engine/graphics/ecs/path/tube/TubePathStyle.js +10 -1
- package/engine/graphics/ecs/path/tube/build/GeometryOutput.js +90 -0
- package/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +3 -2
- package/engine/graphics/ecs/path/tube/build/build_geometry_linear.js +1 -1
- package/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +353 -91
- package/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +390 -0
- package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +16 -0
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -18
- package/engine/graphics/micron/format/MicronGeometry.js +7 -4
- package/engine/graphics/micron/format/micron_build_proxy_geometry.js +203 -0
- package/engine/graphics/micron/plugin/GLTFAssetTransformer.js +21 -0
- package/engine/graphics/micron/prototypeMicronProxyBuild.js +227 -0
- package/engine/graphics/util/composeMatrix4RotationScale.js +4 -27
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +1 -1
- package/engine/navigation/grid/FastBinaryHeap.js +13 -2
- package/package.json +1 -1
|
@@ -35,6 +35,25 @@ function max_polycount(object) {
|
|
|
35
35
|
return r;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {THREE.Object3D} object
|
|
41
|
+
*/
|
|
42
|
+
function ensureProxy(object) {
|
|
43
|
+
if (object.isMicronMesh) {
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type {MicronGeometry}
|
|
47
|
+
*/
|
|
48
|
+
const micron_geo = object.geometry;
|
|
49
|
+
|
|
50
|
+
if (micron_geo.proxy === null) {
|
|
51
|
+
// proxy geometry doesn't exist, build one
|
|
52
|
+
micron_geo.buildProxy();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
38
57
|
export class GLTFAssetTransformer extends AssetTransformer {
|
|
39
58
|
/**
|
|
40
59
|
*
|
|
@@ -171,6 +190,8 @@ export class GLTFAssetTransformer extends AssetTransformer {
|
|
|
171
190
|
|
|
172
191
|
source.override_mesh = micron_root;
|
|
173
192
|
|
|
193
|
+
traverseThreeObject(micron_root, ensureProxy);
|
|
194
|
+
|
|
174
195
|
return source;
|
|
175
196
|
}
|
|
176
197
|
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";
|
|
2
|
+
import {
|
|
3
|
+
AmbientLight,
|
|
4
|
+
CubeTextureLoader,
|
|
5
|
+
DirectionalLight,
|
|
6
|
+
FrontSide,
|
|
7
|
+
Mesh,
|
|
8
|
+
MeshBasicMaterial,
|
|
9
|
+
MeshStandardMaterial,
|
|
10
|
+
PerspectiveCamera,
|
|
11
|
+
PointLight,
|
|
12
|
+
RepeatWrapping,
|
|
13
|
+
Scene,
|
|
14
|
+
SphereGeometry,
|
|
15
|
+
sRGBEncoding,
|
|
16
|
+
TextureLoader,
|
|
17
|
+
VSMShadowMap,
|
|
18
|
+
WebGLRenderer
|
|
19
|
+
} from "three";
|
|
20
|
+
import Stats from "three/examples/jsm/libs/stats.module.js";
|
|
21
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
22
|
+
import { buildMicronGeometryFromBufferGeometry } from "./build/buildMicronGeometryFromBufferGeometry.js";
|
|
23
|
+
|
|
24
|
+
const background = new TextureLoader().load('data/textures/utility/checkers_white_grey_256x256.png');
|
|
25
|
+
background.repeat.set(50, 30);
|
|
26
|
+
background.wrapS = RepeatWrapping;
|
|
27
|
+
background.wrapT = RepeatWrapping;
|
|
28
|
+
|
|
29
|
+
let container, stats;
|
|
30
|
+
|
|
31
|
+
let camera, scene, renderer;
|
|
32
|
+
let directionalLight;
|
|
33
|
+
let pointLight;
|
|
34
|
+
|
|
35
|
+
let windowHalfX = window.innerWidth / 2;
|
|
36
|
+
let windowHalfY = window.innerHeight / 2;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function init() {
|
|
40
|
+
|
|
41
|
+
container = document.createElement("div");
|
|
42
|
+
document.body.appendChild(container);
|
|
43
|
+
|
|
44
|
+
camera = new PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000000);
|
|
45
|
+
camera.position.z = -4000;
|
|
46
|
+
|
|
47
|
+
//
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
scene = new Scene();
|
|
51
|
+
|
|
52
|
+
window.scene = scene;
|
|
53
|
+
|
|
54
|
+
// LIGHTS
|
|
55
|
+
|
|
56
|
+
const ambient = new AmbientLight(0xffffff, 0.1);
|
|
57
|
+
scene.add(ambient);
|
|
58
|
+
|
|
59
|
+
pointLight = new PointLight(0x6666ff, 0.5);
|
|
60
|
+
pointLight.position.y = 1000;
|
|
61
|
+
scene.add(pointLight);
|
|
62
|
+
|
|
63
|
+
// light representation
|
|
64
|
+
|
|
65
|
+
const sphere = new SphereGeometry(100, 16, 8);
|
|
66
|
+
|
|
67
|
+
const mesh = new Mesh(sphere, new MeshBasicMaterial({ color: 0xffffff }));
|
|
68
|
+
mesh.scale.set(0.5, 0.5, 0.5);
|
|
69
|
+
pointLight.add(mesh);
|
|
70
|
+
|
|
71
|
+
// add directional light
|
|
72
|
+
directionalLight = new DirectionalLight(0xFFAAAA, 0.8);
|
|
73
|
+
directionalLight.position.set(-500, 1000, 300);
|
|
74
|
+
directionalLight.castShadow = true;
|
|
75
|
+
const shadow_camera = directionalLight.shadow.camera;
|
|
76
|
+
// small bias to prevent shadow acne
|
|
77
|
+
directionalLight.shadow.bias = -0.0001;
|
|
78
|
+
// directionalLight.shadow.mapSize.set(4096, 4096);
|
|
79
|
+
directionalLight.shadow.mapSize.set(1024, 1024);
|
|
80
|
+
directionalLight.shadow.autoUpdate = false;
|
|
81
|
+
|
|
82
|
+
window.light = directionalLight;
|
|
83
|
+
// directionalLight.shadow.autoUpdate = true;
|
|
84
|
+
|
|
85
|
+
shadow_camera.near = 0.1;
|
|
86
|
+
shadow_camera.far = 2000;
|
|
87
|
+
|
|
88
|
+
const shadow_camera_size = 15;
|
|
89
|
+
|
|
90
|
+
shadow_camera.left = -shadow_camera_size / 2;
|
|
91
|
+
shadow_camera.right = shadow_camera_size / 2;
|
|
92
|
+
|
|
93
|
+
shadow_camera.bottom = -shadow_camera_size / 2;
|
|
94
|
+
shadow_camera.top = shadow_camera_size / 2;
|
|
95
|
+
|
|
96
|
+
shadow_camera.updateProjectionMatrix();
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
scene.add(directionalLight);
|
|
100
|
+
// material samples
|
|
101
|
+
|
|
102
|
+
const cubeMaterial1 = new MeshStandardMaterial({
|
|
103
|
+
wireframe: false,
|
|
104
|
+
side: FrontSide,
|
|
105
|
+
color: 0xffffff
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
//
|
|
109
|
+
|
|
110
|
+
renderer = new WebGLRenderer({
|
|
111
|
+
antialias: true,
|
|
112
|
+
preserveDrawingBuffer: true,
|
|
113
|
+
stencil: false
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
renderer.shadowMap.enabled = true;
|
|
117
|
+
renderer.shadowMap.type = VSMShadowMap;
|
|
118
|
+
// renderer.shadowMap.type = BasicShadowMap;
|
|
119
|
+
renderer.sortObjects = false;
|
|
120
|
+
|
|
121
|
+
renderer.setPixelRatio(window.devicePixelRatio);
|
|
122
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
123
|
+
container.appendChild(renderer.domElement);
|
|
124
|
+
|
|
125
|
+
stats = new Stats();
|
|
126
|
+
container.appendChild(stats.dom);
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
window.addEventListener("resize", onWindowResize);
|
|
130
|
+
|
|
131
|
+
// envmap
|
|
132
|
+
const genCubeUrls = function (prefix, postfix) {
|
|
133
|
+
|
|
134
|
+
return [
|
|
135
|
+
prefix + "posx" + postfix, prefix + "negx" + postfix,
|
|
136
|
+
prefix + "posy" + postfix, prefix + "negy" + postfix,
|
|
137
|
+
prefix + "posz" + postfix, prefix + "negz" + postfix
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const urls = genCubeUrls("data/textures/cubemaps/hip_miramar/32/", ".png");
|
|
143
|
+
|
|
144
|
+
new CubeTextureLoader().load(urls, function (cubeTexture) {
|
|
145
|
+
|
|
146
|
+
cubeTexture.encoding = sRGBEncoding;
|
|
147
|
+
|
|
148
|
+
// scene.background = new Color(0.1, 0.1, 0.1);
|
|
149
|
+
// scene.background = new ThreeColor(1, 0.3, 0.3);
|
|
150
|
+
// scene.background = new Color(0.3, 1, 0.3);
|
|
151
|
+
|
|
152
|
+
scene.background = background;
|
|
153
|
+
scene.environment = cubeTexture;
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// const lightProbe = new LightProbe();
|
|
157
|
+
//
|
|
158
|
+
// lightProbe.copy(LightProbeGenerator.fromCubeTexture(cubeTexture));
|
|
159
|
+
// lightProbe.intensity = 1.2;
|
|
160
|
+
|
|
161
|
+
// scene.add(lightProbe);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
onWindowResize();
|
|
165
|
+
|
|
166
|
+
new PLYLoader().load("data/models/stanford/Lucy100k.ply", async geometry => {
|
|
167
|
+
geometry.computeVertexNormals();
|
|
168
|
+
|
|
169
|
+
const source = new Mesh(geometry, new MeshStandardMaterial({ color: 0xFFFFFF }));
|
|
170
|
+
|
|
171
|
+
const micron_g = await buildMicronGeometryFromBufferGeometry(geometry);
|
|
172
|
+
|
|
173
|
+
micron_g.buildProxy();
|
|
174
|
+
|
|
175
|
+
const proxy = new Mesh(micron_g.proxy, new MeshStandardMaterial({ color: 0xFF0000 }));
|
|
176
|
+
|
|
177
|
+
source.position.x += 700;
|
|
178
|
+
proxy.position.x -= 700;
|
|
179
|
+
|
|
180
|
+
console.warn(geometry, micron_g);
|
|
181
|
+
|
|
182
|
+
scene.add(source);
|
|
183
|
+
scene.add(proxy);
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function onWindowResize() {
|
|
188
|
+
|
|
189
|
+
const w = window.innerWidth;
|
|
190
|
+
const h = window.innerHeight;
|
|
191
|
+
|
|
192
|
+
windowHalfX = w / 2;
|
|
193
|
+
windowHalfY = h / 2;
|
|
194
|
+
|
|
195
|
+
camera.aspect = w / h;
|
|
196
|
+
camera.updateProjectionMatrix();
|
|
197
|
+
|
|
198
|
+
renderer.setSize(w, h);
|
|
199
|
+
|
|
200
|
+
background.repeat.set(w / 20, h / 20);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function animate() {
|
|
204
|
+
|
|
205
|
+
requestAnimationFrame(animate);
|
|
206
|
+
|
|
207
|
+
render();
|
|
208
|
+
stats.update();
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function render() {
|
|
213
|
+
if (orbitControls !== undefined) {
|
|
214
|
+
orbitControls.update();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const timer = -0.0002 * Date.now();
|
|
218
|
+
|
|
219
|
+
pointLight.position.x = 10000 * Math.cos(timer);
|
|
220
|
+
pointLight.position.z = 10000 * Math.sin(timer);
|
|
221
|
+
|
|
222
|
+
renderer.render(scene, camera);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
init();
|
|
226
|
+
const orbitControls = new OrbitControls(camera, container);
|
|
227
|
+
animate();
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { compose_matrix4_array } from "./composeMatrix4.js";
|
|
2
|
+
import Vector3 from "../../../core/geom/Vector3.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
*
|
|
3
6
|
* @param {Matrix4} result
|
|
@@ -7,31 +10,5 @@
|
|
|
7
10
|
export function composeMatrix4RotationScale(result, rotation, scale) {
|
|
8
11
|
const te = result.elements;
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
const x2 = x + x, y2 = y + y, z2 = z + z;
|
|
12
|
-
const xx = x * x2, xy = x * y2, xz = x * z2;
|
|
13
|
-
const yy = y * y2, yz = y * z2, zz = z * z2;
|
|
14
|
-
const wx = w * x2, wy = w * y2, wz = w * z2;
|
|
15
|
-
|
|
16
|
-
const sx = scale.x, sy = scale.y, sz = scale.z;
|
|
17
|
-
|
|
18
|
-
te[0] = (1 - (yy + zz)) * sx;
|
|
19
|
-
te[1] = (xy + wz) * sx;
|
|
20
|
-
te[2] = (xz - wy) * sx;
|
|
21
|
-
te[3] = 0;
|
|
22
|
-
|
|
23
|
-
te[4] = (xy - wz) * sy;
|
|
24
|
-
te[5] = (1 - (xx + zz)) * sy;
|
|
25
|
-
te[6] = (yz + wx) * sy;
|
|
26
|
-
te[7] = 0;
|
|
27
|
-
|
|
28
|
-
te[8] = (xz + wy) * sz;
|
|
29
|
-
te[9] = (yz - wx) * sz;
|
|
30
|
-
te[10] = (1 - (xx + yy)) * sz;
|
|
31
|
-
te[11] = 0;
|
|
32
|
-
|
|
33
|
-
te[12] = 0;
|
|
34
|
-
te[13] = 0;
|
|
35
|
-
te[14] = 0;
|
|
36
|
-
te[15] = 1;
|
|
13
|
+
compose_matrix4_array(te, Vector3.zero, rotation, scale);
|
|
37
14
|
}
|
|
@@ -6,12 +6,15 @@ import { assert } from "../../../core/assert.js";
|
|
|
6
6
|
*/
|
|
7
7
|
class BinaryHeap {
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
10
|
-
* @param {function(T):number} scoreFunction
|
|
9
|
+
* @param {(T)=>number} scoreFunction
|
|
11
10
|
* @constructor
|
|
12
11
|
*/
|
|
13
12
|
constructor(scoreFunction) {
|
|
14
13
|
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {function(T): number}
|
|
17
|
+
*/
|
|
15
18
|
this.scoreFunction = scoreFunction;
|
|
16
19
|
|
|
17
20
|
/**
|
|
@@ -165,6 +168,14 @@ class BinaryHeap {
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* @returns {T|undefined}
|
|
174
|
+
*/
|
|
175
|
+
peek() {
|
|
176
|
+
return this.data[0];
|
|
177
|
+
}
|
|
178
|
+
|
|
168
179
|
/**
|
|
169
180
|
*
|
|
170
181
|
* @param {T} node
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.35.
|
|
8
|
+
"version": "2.35.17",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|