@@ -8,6 +8,7 @@
|
|
8
8
|
import { Camera } from "./Camera.js";
|
9
9
|
import { NeedleEngineHTMLElement } from "../engine/engine_element.js";
|
10
10
|
import { getParam } from "../engine/engine_utils.js";
|
11
|
+
import { Context } from "../engine/engine_context.js";
|
11
12
|
|
12
13
|
const debug = getParam("debugmissingcamera");
|
13
14
|
|
@@ -21,20 +22,23 @@
|
|
21
22
|
|
22
23
|
const camInstance = new Camera();
|
23
24
|
camInstance.sourceId = evt.files?.[0]?.src ?? "unknown"
|
24
|
-
// Set the clearFlags to a skybox
|
25
|
-
|
25
|
+
// Set the clearFlags to a skybox if we have one
|
26
|
+
if((evt.context as Context).lightmaps.tryGetSkybox(camInstance.sourceId))
|
27
|
+
camInstance.clearFlags = 1;
|
28
|
+
else
|
29
|
+
// TODO provide a nice default skybox
|
30
|
+
camInstance.clearFlags = 2;
|
26
31
|
camInstance.backgroundColor = new RGBAColor(0.5, 0.5, 0.5, 1);
|
27
32
|
camInstance.fieldOfView = 35;
|
28
33
|
// TODO: can we store the backgroundBlurriness in the gltf file somewhere except inside the camera?
|
29
34
|
// e.g. when we export a scene from blender without a camera in the scene
|
30
|
-
camInstance.backgroundBlurriness = .
|
35
|
+
camInstance.backgroundBlurriness = .2; // same as in blender 0.5
|
31
36
|
const cam = addNewComponent(cameraObject, camInstance, true) as ICamera;
|
32
37
|
|
33
38
|
cameraObject.position.x = 0;
|
34
39
|
cameraObject.position.y = 1;
|
35
40
|
cameraObject.position.z = 2;
|
36
41
|
|
37
|
-
|
38
42
|
createDefaultCameraControls(evt.context, cam);
|
39
43
|
|
40
44
|
return cam;
|
@@ -134,16 +134,14 @@
|
|
134
134
|
|
135
135
|
const licenseElementIdentifier = "needle-license-element";
|
136
136
|
const licenseDuration = 10000;
|
137
|
-
const licenseDelay =
|
137
|
+
const licenseDelay = 1200;
|
138
138
|
|
139
139
|
async function onNonCommercialVersionDetected(ctx: IContext) {
|
140
140
|
await runtimeLicenseCheckPromise?.catch(() => { });
|
141
141
|
if (hasCommercialLicense()) return;
|
142
142
|
logNonCommercialUse();
|
143
143
|
ctx.domElement.addEventListener("ready", () => {
|
144
|
-
|
145
|
-
insertNonCommercialUseHint(ctx);
|
146
|
-
}, 1000);
|
144
|
+
insertNonCommercialUseHint(ctx);
|
147
145
|
});
|
148
146
|
}
|
149
147
|
|
@@ -152,15 +150,21 @@
|
|
152
150
|
const licenseElement = createLicenseElement();
|
153
151
|
const style = createLicenseStyle();
|
154
152
|
|
155
|
-
const
|
153
|
+
const setAndUpdateStyle = () => {
|
156
154
|
if (!licenseElement) return;
|
157
155
|
const parent = ctx.domElement.shadowRoot || ctx.domElement;
|
158
156
|
if (licenseElement.parentNode !== parent) {
|
159
157
|
parent.appendChild(licenseElement);
|
160
158
|
if (style) parent.appendChild(style);
|
161
159
|
}
|
162
|
-
}
|
160
|
+
};
|
163
161
|
|
162
|
+
// call once and then ensure
|
163
|
+
setAndUpdateStyle();
|
164
|
+
const interval = setInterval(() => {
|
165
|
+
setAndUpdateStyle();
|
166
|
+
}, 1000);
|
167
|
+
|
164
168
|
const svg = `<img class="logo" src="${logoSVG}" style="width: 40px; height: 40px; margin-right: 2px; vertical-align: middle; margin-bottom: 2px;"/>`;
|
165
169
|
const logoElement = document.createElement("div");
|
166
170
|
logoElement.innerHTML = svg;
|
@@ -343,6 +347,24 @@
|
|
343
347
|
transform: scale(1.02) !important;
|
344
348
|
cursor: pointer !important;
|
345
349
|
}
|
350
|
+
|
351
|
+
@media (prefers-reduced-motion: reduce) {
|
352
|
+
${selector} .text {
|
353
|
+
animation: none !important;
|
354
|
+
transition: none !important;
|
355
|
+
/* animation end state */
|
356
|
+
opacity: 1;
|
357
|
+
}
|
358
|
+
|
359
|
+
${selector} .logo {
|
360
|
+
animation: none !important;
|
361
|
+
transition: none !important;
|
362
|
+
/* animation end state */
|
363
|
+
opacity: 1;
|
364
|
+
pointer-events: all;
|
365
|
+
transform: scale(1)
|
366
|
+
}
|
367
|
+
}
|
346
368
|
`
|
347
369
|
return licenseStyle;
|
348
370
|
}
|
@@ -9,8 +9,8 @@
|
|
9
9
|
|
10
10
|
const debug = getParam("debugdecoders");
|
11
11
|
|
12
|
-
const DEFAULT_DRACO_DECODER_LOCATION ='https://www.gstatic.com/draco/versioned/decoders/1.4.1/';
|
13
|
-
const DEFAULT_KTX2_TRANSCODER_LOCATION ='https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/';
|
12
|
+
const DEFAULT_DRACO_DECODER_LOCATION = 'https://www.gstatic.com/draco/versioned/decoders/1.4.1/';
|
13
|
+
const DEFAULT_KTX2_TRANSCODER_LOCATION = 'https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/';
|
14
14
|
|
15
15
|
let dracoLoader: DRACOLoader;
|
16
16
|
let meshoptDecoder: typeof MeshoptDecoder;
|
@@ -59,14 +59,18 @@
|
|
59
59
|
ktx2Loader = new KTX2Loader();
|
60
60
|
ktx2Loader.setTranscoderPath(DEFAULT_KTX2_TRANSCODER_LOCATION);
|
61
61
|
if (debug) console.log("Setting ktx2 transcoder path to", DEFAULT_KTX2_TRANSCODER_LOCATION);
|
62
|
-
if (context.renderer)
|
63
|
-
ktx2Loader.detectSupport(context.renderer);
|
64
62
|
}
|
65
63
|
if (!meshoptDecoder) {
|
66
64
|
meshoptDecoder = MeshoptDecoder;
|
67
65
|
if (debug) console.log("Using the default meshopt decoder");
|
68
66
|
}
|
69
67
|
|
68
|
+
if (context.renderer) {
|
69
|
+
ktx2Loader.detectSupport(context.renderer);
|
70
|
+
}
|
71
|
+
else
|
72
|
+
console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
|
73
|
+
|
70
74
|
loader.setDRACOLoader(dracoLoader);
|
71
75
|
loader.setKTX2Loader(ktx2Loader);
|
72
76
|
loader.setMeshoptDecoder(meshoptDecoder);
|
@@ -94,23 +94,19 @@
|
|
94
94
|
}
|
95
95
|
|
96
96
|
// private lastMatrixWorld!: Matrix4;
|
97
|
-
private lastMatrix
|
98
|
-
private rectBlock
|
97
|
+
private lastMatrix!: Matrix4;
|
98
|
+
private rectBlock!: Object3D;
|
99
99
|
private _transformNeedsUpdate: boolean = false;
|
100
100
|
private _initialPosition!: Vector3;
|
101
101
|
|
102
|
-
constructor() {
|
103
|
-
super();
|
104
|
-
this.lastMatrix = new Matrix4();
|
105
|
-
this.rectBlock = new Object3D();
|
106
|
-
}
|
107
|
-
|
108
102
|
awake() {
|
109
103
|
super.awake();
|
110
104
|
// this is required if an animator animated the transform anchoring
|
111
105
|
if (!this._anchoredPosition)
|
112
106
|
this._anchoredPosition = new Vector2();
|
113
107
|
|
108
|
+
this.lastMatrix = new Matrix4();
|
109
|
+
this.rectBlock = new Object3D();
|
114
110
|
this.rectBlock.name = this.name;
|
115
111
|
|
116
112
|
// TODO: get rid of the initial position
|