@floless/app 0.104.1 → 0.105.0
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/dist/floless-server.cjs +9842 -6508
- package/dist/schemas/steel.model.v2.schema.json +652 -0
- package/dist/schemas/steel.takeoff.v1.schema.json +1 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +109 -5
- package/dist/skills/floless-app-tweak-contract/SKILL.md +23 -7
- package/dist/skills/floless-app-vectorize/SKILL.md +21 -5
- package/dist/templates/steel-model.flo +5 -1
- package/dist/templates/vectorize.flo +5 -1
- package/dist/web/app.css +62 -3
- package/dist/web/aware.js +498 -55
- package/dist/web/index.html +28 -1
- package/dist/web/steel-3d-core.js +242 -0
- package/dist/web/steel-3d-view.js +584 -53
- package/dist/web/steel-editor.html +895 -168
- package/dist/web/steel-filter.html +67 -2
- package/dist/web/steel-materials.js +249 -0
- package/dist/web/steel-model-adapter.js +210 -0
- package/dist/web/steel-model-commands.js +691 -0
- package/dist/web/steel-view-generation.js +10 -1
- package/dist/web/vector-editor.html +118 -3
- package/dist/web/vendor/README.md +6 -1
- package/dist/web/vendor/RoomEnvironment.js +185 -0
- package/dist/web/workspaces.js +345 -26
- package/package.json +6 -1
|
@@ -10,6 +10,15 @@ import { parseLen, fmtLen } from './grid-core.js';
|
|
|
10
10
|
|
|
11
11
|
export const DEFAULT_CUT_MM = 24 * 25.4;
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Display modes a saved view may carry. Must stay a superset of the 3D toolbar's `#m3dMode`
|
|
15
|
+
* buttons in steel-editor.html — a mode the dropdown offers but this list omits is silently
|
|
16
|
+
* downgraded to 'solid' here AND rejected by the contract schema's `views.items.mode` enum,
|
|
17
|
+
* which 400s the PUT and blocks autosave/approval until the view is deleted. Drift between the
|
|
18
|
+
* three is covered by 'saved-view modes stay in step with the 3D display dropdown'.
|
|
19
|
+
*/
|
|
20
|
+
export const VIEW_MODES = ['solid', 'wire', 'xray', 'realistic', 'shadowed'];
|
|
21
|
+
|
|
13
22
|
const finite = (n) => typeof n === 'number' && Number.isFinite(n);
|
|
14
23
|
const positive = (n) => finite(n) && n > 0;
|
|
15
24
|
const vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(finite);
|
|
@@ -167,7 +176,7 @@ export function sanitizeViews(value, makeId = () => `v${Math.random().toString(3
|
|
|
167
176
|
order: finite(raw.order) ? raw.order : out.length,
|
|
168
177
|
camera: raw.camera && typeof raw.camera === 'object' ? raw.camera : null,
|
|
169
178
|
projection: raw.projection === 'ortho' ? 'ortho' : 'persp',
|
|
170
|
-
mode:
|
|
179
|
+
mode: VIEW_MODES.includes(raw.mode) ? raw.mode : 'solid',
|
|
171
180
|
clips: raw.clips && typeof raw.clips === 'object' ? raw.clips : null,
|
|
172
181
|
objects: raw.objects && typeof raw.objects === 'object' ? raw.objects : null,
|
|
173
182
|
};
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
/* Auto-save chip — same states/colors as steel-editor's #saveStat. */
|
|
51
51
|
#saveStat{color:var(--mut);font-size:12px}
|
|
52
52
|
#saveStat.dirty{color:#fbbf24} #saveStat.err{color:#f87171}
|
|
53
|
+
/* Save conflict — the drawing moved under us. NOT .err: the user's document is fine, so it takes the
|
|
54
|
+
existing cyan "non-default, click to act" chip rather than the red failure colour. */
|
|
55
|
+
#saveStat.conflict{color:#22d3ee;border:1px solid #22d3ee;background:rgba(34,211,238,.10);border-radius:4px;padding:1px 6px;cursor:pointer}
|
|
53
56
|
/* Weak-trace review list (inner scroll box — inherits the themed scrollbar rules above). */
|
|
54
57
|
#weakList{max-height:280px;overflow:auto;display:flex;flex-direction:column;gap:2px;margin-top:4px}
|
|
55
58
|
.wrow{display:flex;align-items:center;gap:6px;padding:4px 6px;border-radius:6px;font-size:12px}
|
|
@@ -300,9 +303,15 @@
|
|
|
300
303
|
let saveT = 0;
|
|
301
304
|
function setSaved(state) {
|
|
302
305
|
if (!editable) return;
|
|
303
|
-
const el = $('saveStat'); el.hidden = false; el.classList.remove('dirty', 'err');
|
|
306
|
+
const el = $('saveStat'); el.hidden = false; el.classList.remove('dirty', 'err', 'conflict');
|
|
307
|
+
el.removeAttribute('data-tip'); el.onclick = null;
|
|
304
308
|
if (state === 'dirty') { el.classList.add('dirty'); el.textContent = 'Saving…'; }
|
|
305
309
|
else if (state === 'err') { el.classList.add('err'); el.textContent = 'Save failed'; }
|
|
310
|
+
else if (state === 'conflict') {
|
|
311
|
+
el.classList.add('conflict'); el.textContent = 'Save conflict';
|
|
312
|
+
el.dataset.tip = 'Someone else saved changes to this drawing since you opened it. Your edits are still here — click to choose what to do.';
|
|
313
|
+
el.onclick = () => showConflictBanner(); // the chip never acts on its own; it re-opens the banner
|
|
314
|
+
}
|
|
306
315
|
else el.textContent = 'Saved';
|
|
307
316
|
}
|
|
308
317
|
// PUT the full contract as the server-side draft — the copy Approve bakes. Saves are
|
|
@@ -313,16 +322,119 @@
|
|
|
313
322
|
// LATEST state on the server. Returns the queue tail (ok boolean).
|
|
314
323
|
let saveGen = 0;
|
|
315
324
|
let saveQueue = Promise.resolve(true);
|
|
316
|
-
|
|
325
|
+
let serverEtag = null; // the server's tag for the contract we loaded
|
|
326
|
+
let conflicted = false; // latched once a save is refused, so queued ticks stop re-firing it
|
|
327
|
+
|
|
328
|
+
// `force` REPLACES the precondition rather than skipping it — `If-Match: *` ("must exist") instead of
|
|
329
|
+
// the exact tag, so a deliberate overwrite still cannot create a store from nothing. Only the explicit
|
|
330
|
+
// "Overwrite and save" confirm passes it. (Same correction as steel-editor's `persistServer`: this
|
|
331
|
+
// said "skips the precondition", which was already inaccurate and after P1c describes an impossible
|
|
332
|
+
// request. Fixing one instance and not its twin is the exact miss this PR keeps re-learning.)
|
|
333
|
+
async function doPut(force) {
|
|
334
|
+
// Once conflicted, stop firing doomed writes on every queued tick; re-surface the explanation.
|
|
335
|
+
if (conflicted && !force) { showConflictBanner(); return false; }
|
|
317
336
|
try {
|
|
337
|
+
const headers = { 'content-type': 'application/json' };
|
|
338
|
+
// TOTAL, as of P1c: a write with no precondition is refused (428), so every branch sends one.
|
|
339
|
+
// `*` on force = "must exist", a deliberate overwrite. No tag at all means we read through the
|
|
340
|
+
// BAKED fallback (the GET tags only store-backed documents), i.e. no draft exists yet — so the
|
|
341
|
+
// honest precondition is `If-None-Match: *`, "I believe this store is empty".
|
|
342
|
+
if (force) headers['if-match'] = '*';
|
|
343
|
+
else if (serverEtag) headers['if-match'] = serverEtag;
|
|
344
|
+
else headers['if-none-match'] = '*';
|
|
318
345
|
const res = await fetch('/api/contract/' + encodeURIComponent(app) + PROJECT_QS, {
|
|
319
|
-
method: 'PUT', headers
|
|
346
|
+
method: 'PUT', headers, body: JSON.stringify(C),
|
|
320
347
|
});
|
|
348
|
+
if (res.status === 428) { // a writer here sent no precondition — a bug in our code, not a user error.
|
|
349
|
+
// NOT the conflict copy: nothing else wrote, so "changed somewhere else" would be a lie.
|
|
350
|
+
console.error('save refused 428 — a first-party writer sent no precondition; this is a FloLess bug');
|
|
351
|
+
setSaved('err');
|
|
352
|
+
showConflictBanner('FloLess couldn’t save that change. Reload and try again — if it keeps happening, please report it.', false);
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
if (res.status === 412) { // the user's document is fine — the drawing moved under them
|
|
356
|
+
conflicted = true; setSaved('conflict'); showConflictBanner(); return false;
|
|
357
|
+
}
|
|
358
|
+
if (res.ok) { const t = res.headers.get('ETag'); if (t) serverEtag = t; conflicted = false; }
|
|
321
359
|
setSaved(res.ok ? 'ok' : 'err');
|
|
322
360
|
if (!res.ok) console.error('server save rejected (' + res.status + ')', await res.text().catch(() => ''));
|
|
323
361
|
return res.ok;
|
|
324
362
|
} catch (e) { setSaved('err'); console.error('server save failed', e); return false; }
|
|
325
363
|
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Someone else wrote to this drawing after we loaded it, so the save was refused.
|
|
367
|
+
*
|
|
368
|
+
* Same bar and copy shape as the steel editor — this file already mirrors that surface's save-state
|
|
369
|
+
* CSS by convention, and a user should not have to relearn the signal per surface. A pill alone would
|
|
370
|
+
* not do: this autosaves, so nobody is watching the pill, and a conflict nobody notices means editing
|
|
371
|
+
* a base that will never save. No local-draft trap here (no localStorage draft), so reload is safe.
|
|
372
|
+
*/
|
|
373
|
+
// `message` is optional so the 428 case reuses this bar rather than forking a second one — same bar,
|
|
374
|
+
// same tokens, one thing to learn. Defaults to the write-conflict copy. `allowOverwrite` defaults to
|
|
375
|
+
// true (the conflict case); a 428 passes false, because nothing else wrote and there is nothing to
|
|
376
|
+
// overwrite — offering "Save mine anyway" there would be a lie, and it would re-PUT with If-Match:*.
|
|
377
|
+
function showConflictBanner(message, allowOverwrite) {
|
|
378
|
+
const old = document.getElementById('conflictBanner'); if (old) old.remove();
|
|
379
|
+
const bar = document.createElement('div');
|
|
380
|
+
bar.id = 'conflictBanner';
|
|
381
|
+
bar.style.cssText = 'position:fixed;bottom:0;left:0;right:0;z-index:50;display:flex;align-items:center;gap:10px;'
|
|
382
|
+
+ 'padding:10px 16px;background:#1e40af;color:#e0f2fe;font:13px system-ui;border-top:1px solid #3b82f6;'
|
|
383
|
+
+ 'box-shadow:0 -4px 18px rgba(0,0,0,.45)';
|
|
384
|
+
const msg = document.createElement('span'); msg.style.cssText = 'flex:1';
|
|
385
|
+
msg.textContent = message
|
|
386
|
+
|| 'This drawing was changed somewhere else while you were editing — your changes here didn’t save.';
|
|
387
|
+
const mk = (text, primary) => {
|
|
388
|
+
const b = document.createElement('button');
|
|
389
|
+
b.style.cssText = primary
|
|
390
|
+
? 'background:#3b82f6;color:#fff;border:1px solid #60a5fa;border-radius:6px;padding:5px 12px;cursor:pointer;font:13px system-ui'
|
|
391
|
+
: 'background:transparent;color:#93c5fd;border:1px solid #3b82f6;border-radius:6px;padding:5px 10px;cursor:pointer;font:13px system-ui';
|
|
392
|
+
b.textContent = text; return b;
|
|
393
|
+
};
|
|
394
|
+
const reload = mk('↻ Reload', true); reload.onclick = () => location.reload();
|
|
395
|
+
const dismiss = mk('✕', false); dismiss.onclick = () => bar.remove();
|
|
396
|
+
if (allowOverwrite === false) {
|
|
397
|
+
bar.append(msg, reload, dismiss);
|
|
398
|
+
} else {
|
|
399
|
+
const over = mk('Save mine anyway', false);
|
|
400
|
+
over.dataset.tip = 'Replace the version someone else saved with what you have here';
|
|
401
|
+
over.onclick = () => confirmOverwrite();
|
|
402
|
+
bar.append(msg, reload, over, dismiss);
|
|
403
|
+
}
|
|
404
|
+
document.body.appendChild(bar);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The one destructive choice, so it is the one thing that blocks.
|
|
409
|
+
*
|
|
410
|
+
* Styled modal, never a native confirm (the app forbids native dialogs). Kept secondary and
|
|
411
|
+
* confirm-gated because the AI writing a revision is a first-class action here — a stale tab must not
|
|
412
|
+
* clobber it with one stray click.
|
|
413
|
+
*/
|
|
414
|
+
function confirmOverwrite() {
|
|
415
|
+
const back = document.createElement('div');
|
|
416
|
+
back.style.cssText = 'position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center';
|
|
417
|
+
const shade = document.createElement('div');
|
|
418
|
+
shade.style.cssText = 'position:absolute;inset:0;background:rgba(2,8,23,.62)';
|
|
419
|
+
const panel = document.createElement('div');
|
|
420
|
+
panel.style.cssText = 'position:relative;background:var(--panel,#0f172a);border:1px solid var(--line,#1e293b);'
|
|
421
|
+
+ 'border-radius:10px;width:min(520px,92vw);box-shadow:0 20px 60px rgba(0,0,0,.6)';
|
|
422
|
+
panel.innerHTML = '<div style="padding:14px 16px;border-bottom:1px solid var(--line,#1e293b);font-weight:600">Overwrite the other changes?</div>'
|
|
423
|
+
+ '<div style="padding:14px 16px;line-height:1.5">Someone else saved a version of this drawing after you opened yours. '
|
|
424
|
+
+ 'Saving now replaces their version with what you see here — their changes will be gone for good.</div>'
|
|
425
|
+
+ '<div style="padding:12px 16px;display:flex;gap:8px;justify-content:flex-end;border-top:1px solid var(--line,#1e293b)">'
|
|
426
|
+
+ '<button id=vcfCancel>Cancel</button>'
|
|
427
|
+
+ '<button id=vcfGo style="background:#7f1d1d;border-color:#991b1b;color:#fecaca">Overwrite and save</button></div>';
|
|
428
|
+
back.append(shade, panel);
|
|
429
|
+
document.body.appendChild(back);
|
|
430
|
+
const close = () => back.remove();
|
|
431
|
+
shade.onclick = close;
|
|
432
|
+
panel.querySelector('#vcfCancel').onclick = close;
|
|
433
|
+
panel.querySelector('#vcfGo').onclick = async () => {
|
|
434
|
+
close(); conflicted = false; await doPut(true);
|
|
435
|
+
const bar = document.getElementById('conflictBanner'); if (bar) bar.remove();
|
|
436
|
+
};
|
|
437
|
+
}
|
|
326
438
|
function persistServer() {
|
|
327
439
|
if (!editable || !C) return Promise.resolve(true);
|
|
328
440
|
const gen = ++saveGen;
|
|
@@ -463,6 +575,9 @@
|
|
|
463
575
|
const timer = setTimeout(() => ctrl.abort(), 15000);
|
|
464
576
|
fetch(src, { headers: { accept: 'application/json' }, signal: ctrl.signal })
|
|
465
577
|
.then((r) => {
|
|
578
|
+
// The server's tag for what we just read; echoed back on save so a write that would land on top
|
|
579
|
+
// of someone else's is refused rather than silently winning.
|
|
580
|
+
if (r.ok && editable) serverEtag = r.headers.get('ETag');
|
|
466
581
|
if (!r.ok) {
|
|
467
582
|
// 404 with no contract yet is expected state for a fresh Workspaces project — show the friendly empty-state message
|
|
468
583
|
if (r.status === 404) return null;
|
|
@@ -7,9 +7,14 @@ Pinned, committed (no runtime CDN) so the steel 3D editor renders offline and th
|
|
|
7
7
|
| `three.module.js` | `three/build/three.module.js` (re-exports `./three.core.js`) | **0.184.0** |
|
|
8
8
|
| `three.core.js` | `three/build/three.core.js` (the implementation `three.module.js` imports) | **0.184.0** |
|
|
9
9
|
| `OrbitControls.js` | `three/examples/jsm/controls/OrbitControls.js` | **0.184.0** |
|
|
10
|
+
| `RoomEnvironment.js` | `three/examples/jsm/environments/RoomEnvironment.js` | **0.184.0** |
|
|
10
11
|
| `three-bvh-csg.module.js` | esbuild bundle of `three-bvh-csg` (+ its `three-mesh-bvh` dep), `three` external | three-bvh-csg **0.0.18** / three-mesh-bvh **0.9.10** |
|
|
11
12
|
|
|
12
|
-
`
|
|
13
|
+
`RoomEnvironment.js` is the generated environment the 3D view's **Realistic** display mode reflects —
|
|
14
|
+
metal is nothing but reflections, so with no environment `metalness: 1` renders black. It is generated
|
|
15
|
+
in the browser (via `PMREMGenerator`), so it costs no image asset.
|
|
16
|
+
|
|
17
|
+
`OrbitControls.js`, `RoomEnvironment.js` and `three-bvh-csg.module.js` import the bare specifier `'three'`; `steel-editor.html`
|
|
13
18
|
provides an import map (`"three"` → `./vendor/three.module.js`, `"three/addons/"` → `./vendor/`,
|
|
14
19
|
`"three-bvh-csg"` → `./vendor/three-bvh-csg.module.js`) that resolves them. The CSG bundle powers the steel
|
|
15
20
|
editor's beam **copes** (`steel-3d-view.js` subtracts a `cut` part from the coped member's solid).
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BackSide,
|
|
3
|
+
BoxGeometry,
|
|
4
|
+
InstancedMesh,
|
|
5
|
+
Mesh,
|
|
6
|
+
MeshLambertMaterial,
|
|
7
|
+
MeshStandardMaterial,
|
|
8
|
+
PointLight,
|
|
9
|
+
Scene,
|
|
10
|
+
Object3D,
|
|
11
|
+
} from 'three';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This class represents a scene with a basic room setup that can be used as
|
|
15
|
+
* input for {@link PMREMGenerator#fromScene}. The resulting PMREM represents the room's
|
|
16
|
+
* lighting and can be used for Image Based Lighting by assigning it to {@link Scene#environment}
|
|
17
|
+
* or directly as an environment map to PBR materials.
|
|
18
|
+
*
|
|
19
|
+
* The implementation is based on the [EnvironmentScene](https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts)
|
|
20
|
+
* component from the `model-viewer` project.
|
|
21
|
+
*
|
|
22
|
+
* ```js
|
|
23
|
+
* const environment = new RoomEnvironment();
|
|
24
|
+
* const pmremGenerator = new THREE.PMREMGenerator( renderer );
|
|
25
|
+
*
|
|
26
|
+
* const envMap = pmremGenerator.fromScene( environment ).texture;
|
|
27
|
+
* scene.environment = envMap;
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @augments Scene
|
|
31
|
+
* @three_import import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
|
|
32
|
+
*/
|
|
33
|
+
class RoomEnvironment extends Scene {
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
this.name = 'RoomEnvironment';
|
|
40
|
+
this.position.y = - 3.5;
|
|
41
|
+
|
|
42
|
+
const geometry = new BoxGeometry();
|
|
43
|
+
geometry.deleteAttribute( 'uv' );
|
|
44
|
+
|
|
45
|
+
const roomMaterial = new MeshStandardMaterial( { side: BackSide } );
|
|
46
|
+
const boxMaterial = new MeshStandardMaterial();
|
|
47
|
+
|
|
48
|
+
const mainLight = new PointLight( 0xffffff, 900, 28, 2 );
|
|
49
|
+
mainLight.position.set( 0.418, 16.199, 0.300 );
|
|
50
|
+
this.add( mainLight );
|
|
51
|
+
|
|
52
|
+
const room = new Mesh( geometry, roomMaterial );
|
|
53
|
+
room.position.set( - 0.757, 13.219, 0.717 );
|
|
54
|
+
room.scale.set( 31.713, 28.305, 28.591 );
|
|
55
|
+
this.add( room );
|
|
56
|
+
|
|
57
|
+
const boxes = new InstancedMesh( geometry, boxMaterial, 6 );
|
|
58
|
+
const transform = new Object3D();
|
|
59
|
+
|
|
60
|
+
// box1
|
|
61
|
+
transform.position.set( - 10.906, 2.009, 1.846 );
|
|
62
|
+
transform.rotation.set( 0, - 0.195, 0 );
|
|
63
|
+
transform.scale.set( 2.328, 7.905, 4.651 );
|
|
64
|
+
transform.updateMatrix();
|
|
65
|
+
boxes.setMatrixAt( 0, transform.matrix );
|
|
66
|
+
|
|
67
|
+
// box2
|
|
68
|
+
transform.position.set( - 5.607, - 0.754, - 0.758 );
|
|
69
|
+
transform.rotation.set( 0, 0.994, 0 );
|
|
70
|
+
transform.scale.set( 1.970, 1.534, 3.955 );
|
|
71
|
+
transform.updateMatrix();
|
|
72
|
+
boxes.setMatrixAt( 1, transform.matrix );
|
|
73
|
+
|
|
74
|
+
// box3
|
|
75
|
+
transform.position.set( 6.167, 0.857, 7.803 );
|
|
76
|
+
transform.rotation.set( 0, 0.561, 0 );
|
|
77
|
+
transform.scale.set( 3.927, 6.285, 3.687 );
|
|
78
|
+
transform.updateMatrix();
|
|
79
|
+
boxes.setMatrixAt( 2, transform.matrix );
|
|
80
|
+
|
|
81
|
+
// box4
|
|
82
|
+
transform.position.set( - 2.017, 0.018, 6.124 );
|
|
83
|
+
transform.rotation.set( 0, 0.333, 0 );
|
|
84
|
+
transform.scale.set( 2.002, 4.566, 2.064 );
|
|
85
|
+
transform.updateMatrix();
|
|
86
|
+
boxes.setMatrixAt( 3, transform.matrix );
|
|
87
|
+
|
|
88
|
+
// box5
|
|
89
|
+
transform.position.set( 2.291, - 0.756, - 2.621 );
|
|
90
|
+
transform.rotation.set( 0, - 0.286, 0 );
|
|
91
|
+
transform.scale.set( 1.546, 1.552, 1.496 );
|
|
92
|
+
transform.updateMatrix();
|
|
93
|
+
boxes.setMatrixAt( 4, transform.matrix );
|
|
94
|
+
|
|
95
|
+
// box6
|
|
96
|
+
transform.position.set( - 2.193, - 0.369, - 5.547 );
|
|
97
|
+
transform.rotation.set( 0, 0.516, 0 );
|
|
98
|
+
transform.scale.set( 3.875, 3.487, 2.986 );
|
|
99
|
+
transform.updateMatrix();
|
|
100
|
+
boxes.setMatrixAt( 5, transform.matrix );
|
|
101
|
+
|
|
102
|
+
this.add( boxes );
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
// -x right
|
|
106
|
+
const light1 = new Mesh( geometry, createAreaLightMaterial( 50 ) );
|
|
107
|
+
light1.position.set( - 16.116, 14.37, 8.208 );
|
|
108
|
+
light1.scale.set( 0.1, 2.428, 2.739 );
|
|
109
|
+
this.add( light1 );
|
|
110
|
+
|
|
111
|
+
// -x left
|
|
112
|
+
const light2 = new Mesh( geometry, createAreaLightMaterial( 50 ) );
|
|
113
|
+
light2.position.set( - 16.109, 18.021, - 8.207 );
|
|
114
|
+
light2.scale.set( 0.1, 2.425, 2.751 );
|
|
115
|
+
this.add( light2 );
|
|
116
|
+
|
|
117
|
+
// +x
|
|
118
|
+
const light3 = new Mesh( geometry, createAreaLightMaterial( 17 ) );
|
|
119
|
+
light3.position.set( 14.904, 12.198, - 1.832 );
|
|
120
|
+
light3.scale.set( 0.15, 4.265, 6.331 );
|
|
121
|
+
this.add( light3 );
|
|
122
|
+
|
|
123
|
+
// +z
|
|
124
|
+
const light4 = new Mesh( geometry, createAreaLightMaterial( 43 ) );
|
|
125
|
+
light4.position.set( - 0.462, 8.89, 14.520 );
|
|
126
|
+
light4.scale.set( 4.38, 5.441, 0.088 );
|
|
127
|
+
this.add( light4 );
|
|
128
|
+
|
|
129
|
+
// -z
|
|
130
|
+
const light5 = new Mesh( geometry, createAreaLightMaterial( 20 ) );
|
|
131
|
+
light5.position.set( 3.235, 11.486, - 12.541 );
|
|
132
|
+
light5.scale.set( 2.5, 2.0, 0.1 );
|
|
133
|
+
this.add( light5 );
|
|
134
|
+
|
|
135
|
+
// +y
|
|
136
|
+
const light6 = new Mesh( geometry, createAreaLightMaterial( 100 ) );
|
|
137
|
+
light6.position.set( 0.0, 20.0, 0.0 );
|
|
138
|
+
light6.scale.set( 1.0, 0.1, 1.0 );
|
|
139
|
+
this.add( light6 );
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Frees internal resources. This method should be called
|
|
145
|
+
* when the environment is no longer required.
|
|
146
|
+
*/
|
|
147
|
+
dispose() {
|
|
148
|
+
|
|
149
|
+
const resources = new Set();
|
|
150
|
+
|
|
151
|
+
this.traverse( ( object ) => {
|
|
152
|
+
|
|
153
|
+
if ( object.isMesh ) {
|
|
154
|
+
|
|
155
|
+
resources.add( object.geometry );
|
|
156
|
+
resources.add( object.material );
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
} );
|
|
161
|
+
|
|
162
|
+
for ( const resource of resources ) {
|
|
163
|
+
|
|
164
|
+
resource.dispose();
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function createAreaLightMaterial( intensity ) {
|
|
173
|
+
|
|
174
|
+
// create an emissive-only material. see #31348
|
|
175
|
+
const material = new MeshLambertMaterial( {
|
|
176
|
+
color: 0x000000,
|
|
177
|
+
emissive: 0xffffff,
|
|
178
|
+
emissiveIntensity: intensity
|
|
179
|
+
} );
|
|
180
|
+
|
|
181
|
+
return material;
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export { RoomEnvironment };
|