@needle-tools/engine 2.40.0-pre → 2.41.0-pre
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/CHANGELOG.md +7 -0
- package/dist/needle-engine.d.ts +269 -123
- package/dist/needle-engine.js +389 -389
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +41 -41
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/engine_gizmos.d.ts +1 -0
- package/lib/engine/engine_gizmos.js +16 -4
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_math.d.ts +9 -6
- package/lib/engine/engine_math.js +9 -0
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_physics.js +14 -6
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +2 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -0
- package/lib/engine/engine_utils.js +3 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine-components/AnimationCurve.js +20 -5
- package/lib/engine-components/AnimationCurve.js.map +1 -1
- package/lib/engine-components/Light.d.ts +2 -0
- package/lib/engine-components/Light.js +33 -9
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +15 -26
- package/lib/engine-components/ParticleSystem.js +251 -184
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +208 -63
- package/lib/engine-components/ParticleSystemModules.js +640 -153
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/WebXR.js +8 -3
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +6 -0
- package/lib/engine-components/codegen/components.js +6 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/package.json +3 -1
- package/src/engine/codegen/register_types.js +24 -0
- package/src/engine/engine_gizmos.ts +19 -4
- package/src/engine/engine_math.ts +19 -6
- package/src/engine/engine_physics.ts +17 -7
- package/src/engine/engine_serialization_core.ts +1 -0
- package/src/engine/engine_utils.ts +5 -0
- package/src/engine-components/AnimationCurve.ts +25 -11
- package/src/engine-components/Light.ts +39 -8
- package/src/engine-components/ParticleSystem.ts +314 -194
- package/src/engine-components/ParticleSystemModules.ts +537 -154
- package/src/engine-components/WebXR.ts +11 -8
- package/src/engine-components/codegen/components.ts +6 -0
- package/src/engine/dist/engine_physics.js +0 -739
- package/src/engine/dist/engine_setup.js +0 -777
- package/src/engine-components/dist/CharacterController.js +0 -123
- package/src/engine-components/dist/RigidBody.js +0 -458
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Behaviour, GameObject } from "./Component";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import { getParam } from "../engine/engine_utils";
|
|
3
|
+
import { getParam, isMobileDevice } from "../engine/engine_utils";
|
|
4
4
|
import { setWorldPositionXYZ } from "../engine/engine_three_utils";
|
|
5
5
|
import { FrameEvent } from "../engine/engine_setup";
|
|
6
6
|
import { serializeable } from "../engine/engine_serialization_decorator";
|
|
@@ -8,6 +8,7 @@ import { Color, DirectionalLight, OrthographicCamera } from "three";
|
|
|
8
8
|
import { WebXR, WebXREvent } from "./WebXR";
|
|
9
9
|
import { WebARSessionRoot } from "./WebARSessionRoot";
|
|
10
10
|
import { ILight } from "../engine/engine_types";
|
|
11
|
+
import { Mathf } from "../engine/engine_math";
|
|
11
12
|
|
|
12
13
|
// https://threejs.org/examples/webgl_shadowmap_csm.html
|
|
13
14
|
|
|
@@ -87,6 +88,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
87
88
|
|
|
88
89
|
@serializeable()
|
|
89
90
|
private type: LightType = 0;
|
|
91
|
+
|
|
90
92
|
public range: number = 1;
|
|
91
93
|
public spotAngle: number = 1;
|
|
92
94
|
public innerSpotAngle: number = 1;
|
|
@@ -137,7 +139,8 @@ export class Light extends Behaviour implements ILight {
|
|
|
137
139
|
set shadows(val: LightShadows) {
|
|
138
140
|
this._shadows = val;
|
|
139
141
|
if (this.light) {
|
|
140
|
-
this.light.castShadow = val
|
|
142
|
+
this.light.castShadow = val !== LightShadows.None;
|
|
143
|
+
this.updateShadowSoftHard();
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
get shadows(): LightShadows { return this._shadows; }
|
|
@@ -284,9 +287,9 @@ export class Light extends Behaviour implements ILight {
|
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
createLight() {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (lightAlreadyCreated) {
|
|
290
|
+
const lightAlreadyCreated = this.selfIsLight;
|
|
291
|
+
|
|
292
|
+
if (lightAlreadyCreated && !this.light) {
|
|
290
293
|
this.light = this.gameObject as unknown as THREE.Light;
|
|
291
294
|
|
|
292
295
|
switch (this.type) {
|
|
@@ -295,7 +298,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
295
298
|
break;
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
|
-
else {
|
|
301
|
+
else if(!this.light) {
|
|
299
302
|
switch (this.type) {
|
|
300
303
|
case LightType.Directional:
|
|
301
304
|
// console.log(this);
|
|
@@ -339,7 +342,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
339
342
|
}
|
|
340
343
|
|
|
341
344
|
|
|
342
|
-
if (this.light
|
|
345
|
+
if (this.light) {
|
|
343
346
|
this._intensity = this.light.intensity;
|
|
344
347
|
|
|
345
348
|
if (this.shadows !== LightShadows.None) {
|
|
@@ -356,6 +359,9 @@ export class Light extends Behaviour implements ILight {
|
|
|
356
359
|
this.light.shadow.mapSize.width = 2048;
|
|
357
360
|
this.light.shadow.mapSize.height = 2048;
|
|
358
361
|
}
|
|
362
|
+
// this.light.shadow.needsUpdate = true;
|
|
363
|
+
// console.log(this.light.shadow.mapSize);
|
|
364
|
+
// return;
|
|
359
365
|
|
|
360
366
|
if (debug)
|
|
361
367
|
console.log("Override shadow bias?", this._overrideShadowBiasSettings, this.shadowBias, this.shadowNormalBias);
|
|
@@ -370,7 +376,8 @@ export class Light extends Behaviour implements ILight {
|
|
|
370
376
|
this.light.shadow.normalBias = this.shadowNormalBias * .0001;
|
|
371
377
|
}
|
|
372
378
|
|
|
373
|
-
|
|
379
|
+
this.updateShadowSoftHard();
|
|
380
|
+
|
|
374
381
|
const cam = this.light.shadow.camera as THREE.OrthographicCamera;
|
|
375
382
|
cam.near = this.shadowNearPlane;
|
|
376
383
|
// use shadow distance that was set explictly (if any)
|
|
@@ -399,6 +406,8 @@ export class Light extends Behaviour implements ILight {
|
|
|
399
406
|
cam.top *= sy;
|
|
400
407
|
cam.bottom *= sy;
|
|
401
408
|
}
|
|
409
|
+
|
|
410
|
+
|
|
402
411
|
this.light.shadow.needsUpdate = true;
|
|
403
412
|
if (debug)
|
|
404
413
|
this.context.scene.add(new THREE.CameraHelper(cam));
|
|
@@ -425,6 +434,28 @@ export class Light extends Behaviour implements ILight {
|
|
|
425
434
|
}
|
|
426
435
|
}
|
|
427
436
|
|
|
437
|
+
static allowChangingRendererShadowMapType: boolean = true;
|
|
438
|
+
|
|
439
|
+
private updateShadowSoftHard() {
|
|
440
|
+
if (!this.light) return;
|
|
441
|
+
if (this.shadows === LightShadows.Soft) {
|
|
442
|
+
const radius = this.light.shadow.mapSize.width / 1024 * 5;
|
|
443
|
+
const samples = Mathf.clamp(Math.round(radius), 2, 10);
|
|
444
|
+
this.light.shadow.radius = radius;
|
|
445
|
+
this.light.shadow.blurSamples = samples;
|
|
446
|
+
if (isMobileDevice()) {
|
|
447
|
+
this.light.shadow.radius *= .5;
|
|
448
|
+
this.light.shadow.blurSamples = Math.floor(this.light.shadow.blurSamples * .5);
|
|
449
|
+
}
|
|
450
|
+
if (Light.allowChangingRendererShadowMapType)
|
|
451
|
+
this.context.renderer.shadowMap.type = THREE.VSMShadowMap;
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
this.light.shadow.radius = 1;
|
|
455
|
+
this.light.shadow.blurSamples = 1;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
428
459
|
private setDirectionalLight(dirLight: DirectionalLight) {
|
|
429
460
|
dirLight.add(dirLight.target);
|
|
430
461
|
dirLight.target.position.set(0, 0, -1);
|