Needle Engine

Changes between version 3.41.0-alpha.4 and 3.41.0-alpha.5
Files changed (7) hide show
  1. src/engine-schemes/flatc.exe +0 -0
  2. src/engine-components/ContactShadows.ts +1 -0
  3. src/engine/engine_lods.ts +1 -1
  4. src/engine/extensions/NEEDLE_progressive.ts +1 -1
  5. src/engine/webcomponents/needle menu/needle-menu.ts +2 -1
  6. src/engine-components/RendererLightmap.ts +2 -2
  7. src/engine-components/Skybox.ts +24 -2
src/engine-schemes/flatc.exe DELETED
File without changes
src/engine-components/ContactShadows.ts CHANGED
@@ -214,6 +214,7 @@
214
214
 
215
215
  // max. ground distance is controlled via object scale
216
216
  this.shadowCamera = new OrthographicCamera(-1 / 2, 1 / 2, 1 / 2, -1 / 2, 0, 1.0);
217
+ this.shadowCamera.layers.enableAll();
217
218
  this.shadowCamera.rotation.x = Math.PI / 2; // get the camera to look up
218
219
  this.shadowGroup.add(this.shadowCamera);
219
220
 
src/engine/engine_lods.ts CHANGED
@@ -150,7 +150,7 @@
150
150
  const distance = pos.distanceTo(camWorld);
151
151
  // const vertexCount = mesh.geometry.index!.count / 3;
152
152
  // const vertexCountFactor = Math.min(1, vertexCount / 1000);
153
- const col = colors[Math.min(colors.length - 1, level)] + "88";
153
+ const col = colors[Math.min(colors.length - 1, Math.max(0, level))] + "88";
154
154
  // const size = Math.min(10, radius);
155
155
  const windowScale = this.context.domHeight > 0 ? screen.height / this.context.domHeight : 1;
156
156
  const fieldOfViewScale = (camera as PerspectiveCamera).isPerspectiveCamera ? Math.tan((camera as PerspectiveCamera).fov * Math.PI / 180 / 2) : 1;
src/engine/extensions/NEEDLE_progressive.ts CHANGED
@@ -1,1 +1,1 @@
1
- export * from "@needle-tools/gltf-progressive"
1
+ export { NEEDLE_progressive } from "@needle-tools/gltf-progressive"
src/engine/webcomponents/needle menu/needle-menu.ts CHANGED
@@ -435,7 +435,8 @@
435
435
  // https://github.com/google/material-design-icons/issues/1165
436
436
  ensureFonts();
437
437
  // add to document head AND shadow dom to work
438
- const fontUrl = "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block";
438
+ // using a static font because the variable font is quite large
439
+ const fontUrl = "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0";
439
440
  // const fontUrl = "./include/fonts/MaterialSymbolsOutlined.css"; // for offline support
440
441
  loadFont(fontUrl, { loadedCallback: () => { this.handleSizeChange() } });
441
442
  loadFont(fontUrl, { element: shadow });
src/engine-components/RendererLightmap.ts CHANGED
@@ -43,8 +43,8 @@
43
43
  if (this.lightmapIndex < 0) return;
44
44
  this.lightmapScaleOffset = lightmapScaleOffset;
45
45
  this.lightmapTexture = lightmapTexture;
46
- NEEDLE_progressive.assignTextureLOD(this.lightmapTexture, 0).then(res => {
47
- if (res instanceof Texture) this.lightmapTexture = res;
46
+ NEEDLE_progressive.assignTextureLOD(lightmapTexture, 0).then(res => {
47
+ if ((res as Texture)?.isTexture) this.lightmapTexture = res as Texture;
48
48
  })
49
49
  if (debug == "show") {
50
50
  console.log("Lightmap:", this.gameObject.name, lightmapIndex, "\nScaleOffset:", lightmapScaleOffset, "\nTexture:", lightmapTexture)
src/engine-components/Skybox.ts CHANGED
@@ -39,10 +39,13 @@
39
39
 
40
40
  ContextRegistry.addContextCreatedCallback((args) => {
41
41
  const context = args.context;
42
- const skyboxImage = context.domElement.getAttribute("skybox-image");
43
- const environmentImage = context.domElement.getAttribute("environment-image");
42
+ let skyboxImage = context.domElement.getAttribute("skybox-image");
43
+ let environmentImage = context.domElement.getAttribute("environment-image");
44
44
  const promises = new Array<Promise<any>>();
45
45
 
46
+ skyboxImage = tryParseMagicSkyboxName(skyboxImage);
47
+ environmentImage = tryParseMagicSkyboxName(environmentImage);
48
+
46
49
  if (skyboxImage) {
47
50
  if (debug)
48
51
  console.log("Creating remote skybox to load " + skyboxImage);
@@ -65,6 +68,25 @@
65
68
  return Promise.resolve();
66
69
  });
67
70
 
71
+ function tryParseMagicSkyboxName(str: string | null | undefined): string | null {
72
+ switch (str?.toLowerCase()) {
73
+ case "studio":
74
+ str = "https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";
75
+ break;
76
+ case "blurred-skybox":
77
+ str = "https://cdn.needle.tools/static/skybox/blurred-skybox.exr";
78
+ break;
79
+ case "quicklook-ar":
80
+ str = "https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";
81
+ break;
82
+ case "quicklook":
83
+ str = "https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr";
84
+ break;
85
+ }
86
+ if (str === undefined) return null;
87
+ return str;
88
+ }
89
+
68
90
  declare type SkyboxCacheEntry = { src: string, texture: Promise<Texture> };
69
91
  function ensureGlobalCache() {
70
92
  if (!globalThis["NEEDLE_ENGINE_SKYBOX_TEXTURES"])