@needle-tools/engine 3.2.14-alpha → 3.2.15-alpha

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.14-alpha",
3
+ "version": "3.2.15-alpha",
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",
@@ -1,4 +1,4 @@
1
- import { getParam } from "./engine_utils";
1
+ import { getParam, isMobileDevice } from "./engine_utils";
2
2
  import { ContextEvent, ContextRegistry } from "./engine_context_registry";
3
3
  import { IContext } from "./engine_types";
4
4
  import { logoSVG } from "./assets";
@@ -31,8 +31,8 @@ async function showLicenseInfo(ctx: IContext) {
31
31
 
32
32
 
33
33
  const licenseElementIdentifier = "needle-license-element";
34
- const licenseDuration = 15000;
35
- const licenseDelay = 500;
34
+ const licenseDuration = 5000;
35
+ const licenseDelay = 200;
36
36
 
37
37
  function onNonCommercialVersionDetected(ctx: IContext) {
38
38
  setTimeout(() => insertNonCommercialUseHint(ctx), 2000);
@@ -62,7 +62,8 @@ function insertNonCommercialUseHint(ctx: IContext) {
62
62
 
63
63
  const textElement = document.createElement("div");
64
64
  textElement.classList.add("text");
65
- textElement.innerHTML = "Needle Engine<br/><span class=\"non-commercial\">Non Commercial</span>";
65
+ // if (!isMobileDevice())
66
+ // textElement.innerHTML = "Needle Engine<br/><span class=\"non-commercial\">Non Commercial</span>";
66
67
  licenseElement.appendChild(textElement);
67
68
 
68
69
  licenseElement.title = "Needle Engine — non commercial version";
@@ -157,11 +158,11 @@ function createLicenseStyle() {
157
158
  animation-delay: ${licenseDelay / 1000}s;
158
159
  animation-easing: ease-in-out;
159
160
  mix-blend-mode: difference;
160
- color: rgb(40, 40, 40);
161
+ color: rgb(0, 0, 0);
161
162
  mix-blend-mode: difference;
162
163
  line-height: 1em;
163
164
  margin-left: -3px;
164
- text-shadow: 0 0 2px rgba(200,200,200, .3);
165
+ text-shadow: 0 0 2px rgba(200,200,200, .5);
165
166
  }
166
167
 
167
168
  ${selector} .text .non-commercial {
@@ -175,30 +176,16 @@ function createLicenseStyle() {
175
176
  transform: translate(0px, 10px);
176
177
  pointer-events: none;
177
178
  }
178
- 1% {
179
- transform: translate(0, -5px);
180
- opacity: 1;
181
- }
182
- 2% {
183
- transform: translate(0, 2.5px);
184
- }
185
- 3% {
179
+ 8% {
186
180
  transform: translate(0, 0px);
187
181
  pointer-events: all;
182
+ opacity: 1;
183
+ transform: scale(1.1)
188
184
  }
189
- 4% {
190
- transform: scale(1)
191
- }
192
- 4.5% {
193
- transform: scale(1.3)
194
- }
195
- 6% {
196
- transform: scale(1.32)
197
- }
198
- 7% {
185
+ 20% {
199
186
  transform: scale(1)
200
187
  }
201
- 98% {
188
+ 90% {
202
189
  opacity: 1;
203
190
  pointer-events: all;
204
191
  transform: scale(1)
@@ -186,8 +186,33 @@ export class SceneSwitcher extends Behaviour {
186
186
  return this.select(this._currentIndex - 1);
187
187
  }
188
188
 
189
- select(index: number): Promise<boolean> {
190
- if (debug) console.log("select", index)
189
+ select(index: number | string): Promise<boolean> {
190
+ if (debug) console.log("select", index);
191
+
192
+ if(typeof index === "object"){
193
+ // If a user tries to reference a scene object in a UnityEvent and invoke select(obj)
194
+ // Then the object will be serialized as a object { guid : ... } or with the index json pointer
195
+ // This case is not supported right now. Object references in the editor must not be scene references
196
+ console.warn("Switching to \"" + index + "\" might not work. Please either use an index or a AssetReference (not a scene reference)");
197
+ }
198
+
199
+ if (typeof index === "string") {
200
+ // If the parameter is a string we try to resolve the scene by its uri
201
+ // it's either already known in the scenes array
202
+ // or we create/get a new AssetReference and try to switch to that
203
+ const scene = this.scenes?.find(s => s.uri === index);
204
+ if (!scene) {
205
+ // Ok the scene is unknown to the scene switcher
206
+ // we create a new asset reference (or get an existing one)
207
+ // And switch to that. With this we can not modify the history
208
+ // Until the scene switcher can store the uri in the history instead of the index
209
+ const reference = AssetReference.getOrCreate(this.sourceId ?? "", index, this.context);
210
+ return this.switchScene(reference);
211
+ }
212
+ if (scene) index = this.scenes.indexOf(scene);
213
+ else return couldNotLoadScenePromise;
214
+ }
215
+
191
216
  if (!this.scenes?.length) return couldNotLoadScenePromise;
192
217
  if (index < 0) {
193
218
  if (this.clamp) return couldNotLoadScenePromise;
@@ -225,7 +250,7 @@ export class SceneSwitcher extends Behaviour {
225
250
  GameObject.add(scene.asset, this.gameObject);
226
251
  if (this.useSceneLighting)
227
252
  this.context.sceneLighting.enable(scene)
228
- if (this.useHistory) {
253
+ if (this.useHistory && index >= 0) {
229
254
  // save the loaded scene as an url parameter
230
255
  if (this.queryParameterName?.length)
231
256
  setParamWithoutReload(this.queryParameterName, index.toString(), this.useHistory);
@@ -12,6 +12,7 @@ import { serializable } from "../../../engine/engine_serialization";
12
12
  import { isDevEnvironment, showBalloonMessage, showBalloonWarning } from "../../../engine/debug/debug";
13
13
  import { Context } from "../../../engine/engine_setup";
14
14
  import { WebARSessionRoot } from "../../webxr/WebARSessionRoot";
15
+ import { hasProLicense } from "../../../engine/engine_license";
15
16
 
16
17
  const debug = getParam("debugusdz");
17
18
 
@@ -36,6 +37,9 @@ export class USDZExporter extends Behaviour {
36
37
  @serializable()
37
38
  autoExportAnimations: boolean = false;
38
39
 
40
+ @serializable()
41
+ exportFileName?: string;
42
+
39
43
  @serializable(QuickLookOverlay)
40
44
  overlay?: QuickLookOverlay;
41
45
 
@@ -130,8 +134,9 @@ export class USDZExporter extends Behaviour {
130
134
  const eventArgs = { self: this, exporter: exporter, extensions: extensions, object: this.objectToExport };
131
135
  this.dispatchEvent(new CustomEvent("before-export", { detail: eventArgs }))
132
136
 
133
- let name = "needle";
137
+ let name = this.exportFileName ?? this.objectToExport?.name ?? this.name;
134
138
  if (debug) name += "-" + getFormattedDate();
139
+ else if (!hasProLicense()) name = name + " - Made with Needle";
135
140
 
136
141
  //@ts-ignore
137
142
  exporter.debug = debug;
@@ -151,7 +156,7 @@ export class USDZExporter extends Behaviour {
151
156
 
152
157
  // see https://developer.apple.com/documentation/arkit/adding_an_apple_pay_button_or_a_custom_action_in_ar_quick_look
153
158
  const overlay = this.buildQuicklookOverlay();
154
- console.log(overlay);
159
+ if(debug) console.log(overlay);
155
160
  const callToAction = overlay.callToAction ? encodeURIComponent(overlay.callToAction) : "";
156
161
  const checkoutTitle = overlay.checkoutTitle ? encodeURIComponent(overlay.checkoutTitle) : "";
157
162
  const checkoutSubtitle = overlay.checkoutSubtitle ? encodeURIComponent(overlay.checkoutSubtitle) : "";