@needle-tools/engine 2.60.4-pre → 2.61.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "2.60.4-pre",
3
+ "version": "2.61.0-pre",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "module": "dist/needle-engine.js",
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@babel/runtime": "^7.16.0",
58
58
  "@luncheon/esbuild-plugin-gzip": "^0.1.0",
59
- "@needle-tools/gltf-transform-extensions": "^0.11.1-pre",
59
+ "@needle-tools/gltf-transform-extensions": "^0.11.2-pre",
60
60
  "@needle-tools/needle-component-compiler": "1.9.3",
61
61
  "@needle-tools/helper": "^0.2.1-pre",
62
62
  "@types/three": "0.146.0",
@@ -652,7 +652,7 @@ class RootMotionAction {
652
652
  // lastRotation.invert().premultiply(firstKeyframe).invert();
653
653
  RootMotionAction.spaceRotation[this.clip.uuid].copy(lastRotation);
654
654
 
655
- // if (debugRootMotion)
655
+ if (debugRootMotion)
656
656
  {
657
657
  const euler = new THREE.Euler().setFromQuaternion(lastRotation);
658
658
  console.log("START", this.clip.name, Mathf.toDegrees(euler.y));
@@ -131,7 +131,7 @@ export class Light extends Behaviour implements ILight {
131
131
  }
132
132
  }
133
133
  get shadowNormalBias(): number { return this._shadowNormalBias; }
134
- private _shadowNormalBias: number = 1;
134
+ private _shadowNormalBias: number = 0;
135
135
 
136
136
  /** when enabled this will remove the multiplication when setting the shadow bias settings initially */
137
137
  private _overrideShadowBiasSettings: boolean = false;
@@ -242,6 +242,7 @@ export class Light extends Behaviour implements ILight {
242
242
 
243
243
  awake() {
244
244
  this.color = new THREE.Color(this.color ?? 0xffffff);
245
+ if(debug) console.log(this.name, this);
245
246
  }
246
247
 
247
248
  onEnable(): void {
@@ -10,15 +10,17 @@ import { serializable } from "../engine/engine_serialization";
10
10
  import { RGBAColor } from "./js-extensions/RGBAColor";
11
11
  import { AxesHelper, BufferGeometry, Color, Material, Matrix4, Mesh, MeshStandardMaterial, Object3D, OneMinusDstAlphaFactor, PlaneGeometry, Quaternion, Sprite, SpriteMaterial, Vector3, Vector4 } from "three";
12
12
  import { getWorldPosition, getWorldQuaternion, getWorldScale } from "../engine/engine_three_utils";
13
- import { assign, deserializeObject } from "../engine/engine_serialization_core";
13
+ import { assign } from "../engine/engine_serialization_core";
14
14
  import { BatchedParticleRenderer, Behavior, BillBoardSettings, BurstParameters, ColorGenerator, ConstantColor, ConstantValue, EmissionState, EmitSubParticleSystem, EmitterShape, FunctionColorGenerator, FunctionJSON, FunctionValueGenerator, IntervalValue, MeshSettings, Particle, ParticleEmitter, ParticleSystem as _ParticleSystem, ParticleSystemParameters, PointEmitter, RecordState, RenderMode, RotationGenerator, SizeOverLife, TrailBatch, TrailParticle, TrailSettings, ValueGenerator } from "three.quarks";
15
15
  import { createFlatTexture } from "../engine/engine_shaders";
16
16
  import { Mathf } from "../engine/engine_math";
17
17
  import { Context } from "../engine/engine_setup";
18
18
  import { ParticleSubEmitter } from "./ParticleSystemSubEmitter";
19
- import { copyFile } from "fs";
19
+ import { NEEDLE_progressive } from "../engine/extensions/NEEDLE_progressive";
20
20
 
21
21
  const debug = getParam("debugparticles");
22
+ const suppressProgressiveLoading = getParam("noprogressive");
23
+ const debugProgressiveLoading = getParam("debugprogressive");
22
24
 
23
25
  export enum SubEmitterType {
24
26
  Birth = 0,
@@ -46,8 +48,6 @@ export class SubEmitterSystem {
46
48
  }
47
49
  }
48
50
 
49
-
50
-
51
51
  export class ParticleSystemRenderer extends Behaviour {
52
52
 
53
53
  @serializable()
@@ -69,8 +69,19 @@ export class ParticleSystemRenderer extends Behaviour {
69
69
  }
70
70
 
71
71
  getMaterial(trailEnabled: boolean = false) {
72
- if (trailEnabled === true && this.trailMaterial) return this.trailMaterial;
73
- return this.particleMaterial;
72
+ const material = (trailEnabled === true && this.trailMaterial) ? this.trailMaterial : this.particleMaterial;
73
+
74
+ // progressive load on start
75
+ // TODO: figure out how to do this before particle system rendering so we only load textures for visible materials
76
+ if (material && !suppressProgressiveLoading && material["_didRequestTextureLOD"] === undefined) {
77
+ material["_didRequestTextureLOD"] = 0;
78
+ if (debugProgressiveLoading) {
79
+ console.log("Load material LOD", material.name);
80
+ }
81
+ NEEDLE_progressive.assignTextureLOD(this.context, this.sourceId, material);
82
+ }
83
+
84
+ return material;
74
85
  }
75
86
 
76
87
  getMesh(renderMode?: ParticleSystemRenderMode) {
@@ -830,7 +841,14 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
830
841
  if (this._time > this.duration) this._time = 0;
831
842
  }
832
843
 
844
+ private lastMaterialVersion: number = -1;
833
845
  private onUpdate() {
846
+ const mat = this.renderer.getMaterial(this.trails.enabled);
847
+ if (mat && mat.version != this.lastMaterialVersion && this._particleSystem) {
848
+ this.lastMaterialVersion = mat.version;
849
+ this._particleSystem.texture = this._interface.texture;
850
+ }
851
+
834
852
  if (this._bursts) {
835
853
  this.emission.bursts = this._bursts;
836
854
  delete this._bursts;
@@ -285,7 +285,7 @@ export class Renderer extends Behaviour implements IRenderer {
285
285
  return lm !== null && lm !== undefined;
286
286
  }
287
287
 
288
- allowProgressiveLoading: boolean = true;
288
+ public allowProgressiveLoading: boolean = true;
289
289
 
290
290
  registering() {
291
291
  if (!this.enabled) {
@@ -546,7 +546,6 @@ export class Renderer extends Behaviour implements IRenderer {
546
546
  console.log("Load material LOD", material.name);
547
547
  }
548
548
  NEEDLE_progressive.assignTextureLOD(this.context, this.sourceId, material);
549
-
550
549
  }
551
550
 
552
551
  if (material.envMapIntensity !== undefined) {
@@ -117,6 +117,9 @@ export class Canvas extends UIRootComponent {
117
117
  }
118
118
  }
119
119
 
120
+ applyRenderSettings(){
121
+ this.onRenderSettingsChanged();
122
+ }
120
123
 
121
124
  private _updateRenderSettingsRoutine?: Generator;
122
125
  private onRenderSettingsChanged() {