@needle-tools/engine 3.2.5-alpha → 3.2.5-alpha.1

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": "3.2.5-alpha",
3
+ "version": "3.2.5-alpha.1",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "type": "module",
package/src/engine/api.ts CHANGED
@@ -33,6 +33,7 @@ export * from "./js-extensions";
33
33
  export * from "./engine_scenetools";
34
34
  export * from "./engine_serialization";
35
35
  export * from "./engine_texture";
36
+ export * from "./engine_three_utils";
36
37
  export * from "./engine_time";
37
38
  export * from "./engine_types";
38
39
  export * from "./engine_utils_screenshot";
@@ -1,4 +1,4 @@
1
- import { Vector4, EquirectangularReflectionMapping, sRGBEncoding, WebGLCubeRenderTarget, Texture, LightProbe, Color } from "three";
1
+ import { Vector4, EquirectangularReflectionMapping, sRGBEncoding, WebGLCubeRenderTarget, Texture, LightProbe, Color, SphericalHarmonics3 } from "three";
2
2
  import { LightProbeGenerator } from "three/examples/jsm/lights/LightProbeGenerator.js"
3
3
  import { Context } from "./engine_setup";
4
4
  import { SceneLightSettings } from "./extensions/NEEDLE_lighting_settings";
@@ -11,7 +11,7 @@ const debug = getParam("debugenvlight");
11
11
 
12
12
  export declare type SphericalHarmonicsData = {
13
13
  array: number[],
14
- texture: THREE.WebGLCubeRenderTarget | THREE.Texture,
14
+ texture: WebGLCubeRenderTarget | Texture,
15
15
  lightProbe?: LightProbe
16
16
  }
17
17
 
@@ -136,8 +136,8 @@ export class RendererData {
136
136
  }
137
137
  }
138
138
 
139
- disableReflection(sourceId? : SourceIdentifier) {
140
- if(sourceId && sourceId !== this._currentReflectionId) return;
139
+ disableReflection(sourceId?: SourceIdentifier) {
140
+ if (sourceId && sourceId !== this._currentReflectionId) return;
141
141
  const scene = this.context.scene;
142
142
  scene.environment = null;
143
143
  }
@@ -178,13 +178,13 @@ export class LightData {
178
178
  get Array(): number[] | undefined { return this._sphericalHarmonicsArray; }
179
179
 
180
180
  private _context: Context;
181
- private _source: THREE.Texture;
182
- private _sphericalHarmonics: THREE.SphericalHarmonics3 | null = null;
181
+ private _source: Texture;
182
+ private _sphericalHarmonics: SphericalHarmonics3 | null = null;
183
183
  private _sphericalHarmonicsArray?: number[];
184
184
  private _ambientScale: number = 1;
185
185
  private _lightProbe?: LightProbe;
186
186
 
187
- constructor(context: Context, tex: THREE.Texture, ambientScale: number = 1) {
187
+ constructor(context: Context, tex: Texture, ambientScale: number = 1) {
188
188
  this._context = context;
189
189
  this._source = tex;
190
190
  this._ambientScale = ambientScale;
@@ -199,7 +199,7 @@ export class LightData {
199
199
 
200
200
  try {
201
201
  const reflection = this._source;
202
- let rt: THREE.WebGLCubeRenderTarget | null = null;
202
+ let rt: WebGLCubeRenderTarget | null = null;
203
203
  if (reflection) {
204
204
  if (debug) console.log("GENERATING LIGHT PROBE", reflection, this.Source);
205
205
  const size = Math.min(reflection.image.width, 512);
@@ -216,13 +216,15 @@ export class LightData {
216
216
  // console.log(intensityFactor, lightFactor);
217
217
  this._sphericalHarmonics = sampledProbe.sh;
218
218
  this._sphericalHarmonicsArray = this._sphericalHarmonics.toArray();
219
- const factor = ((intensityFactor) / (Math.PI * .5));
220
- for (let i = 0; i < this._sphericalHarmonicsArray.length; i++) {
221
- this._sphericalHarmonicsArray[i] *= factor;
219
+ if (this._sphericalHarmonicsArray) {
220
+ const factor = ((intensityFactor) / (Math.PI * .5));
221
+ for (let i = 0; i < this._sphericalHarmonicsArray.length; i++) {
222
+ this._sphericalHarmonicsArray[i] *= factor;
223
+ }
224
+ sampledProbe.sh.scale(lightFactor);
225
+ if (this._source)
226
+ return { array: this._sphericalHarmonicsArray, texture: this._source, lightProbe: sampledProbe };
222
227
  }
223
- sampledProbe.sh.scale(lightFactor);
224
- if (this._source)
225
- return { array: this._sphericalHarmonicsArray, texture: this._source, lightProbe: sampledProbe };
226
228
  }
227
229
  }
228
230
  catch (err) {
@@ -1,2 +1,3 @@
1
1
  export * from "./WebXR";
2
- export * from "./WebXRPlaneTracking";
2
+ export * from "./WebXRPlaneTracking";
3
+ export * from "./WebXRController";