Needle Engine

Changes between version 3.39.0-alpha.5 and 3.40.0-alpha
Files changed (3) hide show
  1. src/engine/engine_lods.ts +17 -15
  2. src/engine-components/ui/Graphic.ts +1 -0
  3. src/engine-components/OrbitControls.ts +7 -2
src/engine/engine_lods.ts CHANGED
@@ -75,7 +75,7 @@
75
75
 
76
76
 
77
77
  let level = results.mesh_lod;
78
- const changed = results.mesh_lod != state.lastLodLevel_Mesh || results.texture_lod != state.lasLodLevel_Texture;
78
+ const changed = results.mesh_lod != state.lastLodLevel_Mesh || results.texture_lod != state.lastLodLevel_Texture;
79
79
 
80
80
  if (debug && mesh.geometry.boundingSphere) {
81
81
  const bounds = mesh.geometry.boundingSphere;
@@ -139,21 +139,23 @@
139
139
  // helper?.setText(text);
140
140
  // continue;
141
141
  // }
142
- const cam = camera as any as IGameObject;
143
- const camForward = cam.worldForward;
144
- const camWorld = cam.worldPosition;
142
+ if (state.lastScreenCoverage > .1) {
143
+ const cam = camera as any as IGameObject;
144
+ const camForward = cam.worldForward;
145
+ const camWorld = cam.worldPosition;
145
146
 
146
- const fwd = getTempVector(camForward);
147
- // for debugging very close LDOs, we need to flip the radius...
148
- const pos = fwd.multiplyScalar(radius * .7).add(boundsCenter);
149
- const distance = pos.distanceTo(camWorld);
150
- // const vertexCount = mesh.geometry.index!.count / 3;
151
- // const vertexCountFactor = Math.min(1, vertexCount / 1000);
152
- const col = colors[Math.min(colors.length - 1, level)] + "88";
153
- // const size = Math.min(10, radius);
154
- const windowScale = this.context.domHeight > 0 ? screen.height / this.context.domHeight : 1;
155
- const fieldOfViewScale = (camera as PerspectiveCamera).isPerspectiveCamera ? Math.tan((camera as PerspectiveCamera).fov * Math.PI / 180 / 2) : 1;
156
- Gizmos.DrawLabel(pos, text, distance * .012 * windowScale * fieldOfViewScale, undefined, 0xffffff, col);
147
+ const fwd = getTempVector(camForward);
148
+ // for debugging very close LDOs, we need to flip the radius...
149
+ const pos = fwd.multiplyScalar(radius * .7).add(boundsCenter);
150
+ const distance = pos.distanceTo(camWorld);
151
+ // const vertexCount = mesh.geometry.index!.count / 3;
152
+ // const vertexCountFactor = Math.min(1, vertexCount / 1000);
153
+ const col = colors[Math.min(colors.length - 1, level)] + "88";
154
+ // const size = Math.min(10, radius);
155
+ const windowScale = this.context.domHeight > 0 ? screen.height / this.context.domHeight : 1;
156
+ const fieldOfViewScale = (camera as PerspectiveCamera).isPerspectiveCamera ? Math.tan((camera as PerspectiveCamera).fov * Math.PI / 180 / 2) : 1;
157
+ Gizmos.DrawLabel(pos, text, distance * .012 * windowScale * fieldOfViewScale, undefined, 0xffffff, col);
158
+ }
157
159
  }
158
160
 
159
161
  }
src/engine-components/ui/Graphic.ts CHANGED
@@ -224,6 +224,7 @@
224
224
  this.setOptions({ backgroundImage: tex, borderRadius: 0, backgroundOpacity: this.color.alpha, backgroundSize: "stretch" });
225
225
  NEEDLE_progressive.assignTextureLOD(tex, 0).then(res => {
226
226
  if (res instanceof Texture) {
227
+ if (tex) Graphic.textureCache.set(tex, res);
227
228
  this.setOptions({ backgroundImage: res });
228
229
  this.markDirty();
229
230
  }
src/engine-components/OrbitControls.ts CHANGED
@@ -536,7 +536,11 @@
536
536
  if (debugCameraFit)
537
537
  console.log("OrbitControls hits", ...hits);
538
538
  }
539
- if (this.autoFit) this.fitCamera()
539
+ if (this.autoFit)
540
+ this.fitCamera(this.scene.children, {
541
+ centerCamera: "y",
542
+ immediate: true,
543
+ })
540
544
  }
541
545
  }
542
546
 
@@ -698,7 +702,8 @@
698
702
  return;
699
703
  }
700
704
 
701
- let { fitOffset, immediate, centerCamera } = options;
705
+ const { immediate, centerCamera } = options;
706
+ let { fitOffset } = options;
702
707
 
703
708
  if (fitOffset == undefined) {
704
709
  fitOffset = 1.1;