entangled-worlds-orbiters-shared 1.0.8 → 1.1.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/LICENSE +21 -0
- package/README.md +12 -5
- package/THIRD-PARTY-NOTICES.md +5 -0
- package/package.json +5 -4
- package/src/index.js +0 -1
- package/src/utils/dispose.js +20 -4
- package/src/arrow-ui/BooleanController.js +0 -31
- package/src/arrow-ui/ColorController.js +0 -108
- package/src/arrow-ui/Controller.js +0 -447
- package/src/arrow-ui/FunctionController.js +0 -27
- package/src/arrow-ui/GUI.js +0 -595
- package/src/arrow-ui/NumberController.js +0 -567
- package/src/arrow-ui/OptionController.js +0 -64
- package/src/arrow-ui/StringController.js +0 -41
- package/src/arrow-ui/index.js +0 -13
- package/src/arrow-ui/lilGuiLoader.js +0 -10
- package/src/arrow-ui/utils/getColorFormat.js +0 -75
- package/src/arrow-ui/utils/injectStyles.js +0 -10
- package/src/arrow-ui/utils/normalizeColorString.js +0 -29
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Plantasia Space
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -16,15 +16,20 @@ A shared library containing core components for 3D world rendering, moons system
|
|
|
16
16
|
```bash
|
|
17
17
|
npm install entangled-worlds-orbiters-shared
|
|
18
18
|
```
|
|
19
|
-
## Test locally
|
|
19
|
+
## Test locally
|
|
20
20
|
|
|
21
|
-
In
|
|
22
|
-
|
|
21
|
+
In `entangled-worlds-orbiters-shared/`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install
|
|
23
25
|
npm link
|
|
26
|
+
```
|
|
24
27
|
|
|
25
|
-
In
|
|
28
|
+
In the consuming app (`entangled-worlds/` or `orbiters/`):
|
|
26
29
|
|
|
30
|
+
```bash
|
|
27
31
|
npm link entangled-worlds-orbiters-shared
|
|
32
|
+
```
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
## Usage
|
|
@@ -124,4 +129,6 @@ npm install three three-stdlib
|
|
|
124
129
|
|
|
125
130
|
## License
|
|
126
131
|
|
|
127
|
-
MIT
|
|
132
|
+
[MIT](LICENSE) © Plantasia Space.
|
|
133
|
+
|
|
134
|
+
`src/arrow-ui/` is derived from [lil-gui](https://github.com/georgealways/lil-gui) (MIT) — see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## Arrow UI (`src/arrow-ui/`)
|
|
4
|
+
|
|
5
|
+
Derived from [lil-gui](https://github.com/georgealways/lil-gui) by George Michael Brower, licensed under the [MIT License](https://github.com/georgealways/lil-gui/blob/master/LICENSE). The controllers and GUI core have been adapted for the Entangled Worlds / Orbiters apps (external stylesheet loading, custom controllers and behavior); the original license applies to the derived portions alongside this project's MIT license.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "entangled-worlds-orbiters-shared",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared library for entangled worlds orbiters - contains core world rendering, moons system, and UI components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
".": "./src/index.js",
|
|
9
9
|
"./world": "./src/world/index.js",
|
|
10
10
|
"./moons": "./src/moons/index.js",
|
|
11
|
-
"./arrow-ui": "./src/arrow-ui/index.js",
|
|
12
11
|
"./loaders": "./src/loaders/index.js",
|
|
13
12
|
"./core": "./src/core/index.js",
|
|
14
13
|
"./config": "./src/config/index.js",
|
|
@@ -17,7 +16,9 @@
|
|
|
17
16
|
"files": [
|
|
18
17
|
"src/**/*",
|
|
19
18
|
"public/**/*",
|
|
20
|
-
"README.md"
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"THIRD-PARTY-NOTICES.md"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [
|
|
23
24
|
"three.js",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"repository": {
|
|
45
46
|
"type": "git",
|
|
46
|
-
"url": "git+
|
|
47
|
+
"url": "git+https://github.com/plantasia-space-org/entangled-worlds-orbiters-shared.git"
|
|
47
48
|
},
|
|
48
49
|
"bugs": {
|
|
49
50
|
"url": "https://github.com/plantasia-space-org/entangled-worlds-orbiters-shared/issues"
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Main exports for entangled-worlds-orbiters-shared library
|
|
2
2
|
export * from './world/index.js';
|
|
3
3
|
export * from './moons/index.js';
|
|
4
|
-
export * from './arrow-ui/index.js';
|
|
5
4
|
export * from './loaders/index.js';
|
|
6
5
|
export * from './core/index.js';
|
|
7
6
|
export * from './config/index.js';
|
package/src/utils/dispose.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
// Three.js GPU resources are not garbage-collected — geometries, materials, and
|
|
2
|
+
// the textures hanging off materials must be disposed explicitly on teardown, or
|
|
3
|
+
// the consuming app leaks VRAM on every world swap / moon rebuild.
|
|
4
|
+
|
|
1
5
|
export function disposeMaterial(material) {
|
|
2
6
|
if (!material) return;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
// A mesh can carry a single material or an array (multi-material meshes, some GLB).
|
|
8
|
+
const materials = Array.isArray(material) ? material : [material];
|
|
9
|
+
for (const mat of materials) {
|
|
10
|
+
if (!mat) continue;
|
|
11
|
+
// Free the textures (and any other disposable values) hanging off the material…
|
|
12
|
+
for (const key in mat) {
|
|
13
|
+
const val = mat[key];
|
|
14
|
+
if (val && typeof val.dispose === 'function') {
|
|
15
|
+
try { val.dispose(); } catch {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// …then free the material's own GPU program. Without this the shader program
|
|
19
|
+
// leaks even though its textures were released. `dispose` is a prototype method,
|
|
20
|
+
// so the loop above never reaches it — no double-dispose.
|
|
21
|
+
if (typeof mat.dispose === 'function') {
|
|
22
|
+
try { mat.dispose(); } catch {}
|
|
7
23
|
}
|
|
8
24
|
}
|
|
9
25
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Controller from './Controller';
|
|
2
|
-
|
|
3
|
-
export default class BooleanController extends Controller {
|
|
4
|
-
|
|
5
|
-
constructor( parent, object, property ) {
|
|
6
|
-
|
|
7
|
-
super( parent, object, property, 'boolean', 'label' );
|
|
8
|
-
|
|
9
|
-
this.$input = document.createElement( 'input' );
|
|
10
|
-
this.$input.setAttribute( 'type', 'checkbox' );
|
|
11
|
-
this.$input.setAttribute( 'aria-labelledby', this.$name.id );
|
|
12
|
-
|
|
13
|
-
this.$widget.appendChild( this.$input );
|
|
14
|
-
|
|
15
|
-
this.$input.addEventListener( 'change', () => {
|
|
16
|
-
this.setValue( this.$input.checked );
|
|
17
|
-
this._callOnFinishChange();
|
|
18
|
-
} );
|
|
19
|
-
|
|
20
|
-
this.$disable = this.$input;
|
|
21
|
-
|
|
22
|
-
this.updateDisplay();
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
updateDisplay() {
|
|
27
|
-
this.$input.checked = this.getValue();
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import Controller from './Controller';
|
|
2
|
-
|
|
3
|
-
import getColorFormat from './utils/getColorFormat';
|
|
4
|
-
import normalizeColorString from './utils/normalizeColorString';
|
|
5
|
-
|
|
6
|
-
export default class ColorController extends Controller {
|
|
7
|
-
|
|
8
|
-
constructor( parent, object, property, rgbScale ) {
|
|
9
|
-
|
|
10
|
-
super( parent, object, property, 'color' );
|
|
11
|
-
|
|
12
|
-
this.$input = document.createElement( 'input' );
|
|
13
|
-
this.$input.setAttribute( 'type', 'color' );
|
|
14
|
-
this.$input.setAttribute( 'tabindex', -1 );
|
|
15
|
-
this.$input.setAttribute( 'aria-labelledby', this.$name.id );
|
|
16
|
-
|
|
17
|
-
this.$text = document.createElement( 'input' );
|
|
18
|
-
this.$text.setAttribute( 'type', 'text' );
|
|
19
|
-
this.$text.setAttribute( 'spellcheck', 'false' );
|
|
20
|
-
this.$text.setAttribute( 'aria-labelledby', this.$name.id );
|
|
21
|
-
|
|
22
|
-
this.$display = document.createElement( 'div' );
|
|
23
|
-
this.$display.classList.add( 'display' );
|
|
24
|
-
|
|
25
|
-
this.$display.appendChild( this.$input );
|
|
26
|
-
this.$widget.appendChild( this.$display );
|
|
27
|
-
this.$widget.appendChild( this.$text );
|
|
28
|
-
|
|
29
|
-
this._format = getColorFormat( this.initialValue );
|
|
30
|
-
this._rgbScale = rgbScale;
|
|
31
|
-
|
|
32
|
-
this._initialValueHexString = this.save();
|
|
33
|
-
this._textFocused = false;
|
|
34
|
-
|
|
35
|
-
this.$input.addEventListener( 'input', () => {
|
|
36
|
-
this._setValueFromHexString( this.$input.value );
|
|
37
|
-
} );
|
|
38
|
-
|
|
39
|
-
this.$input.addEventListener( 'blur', () => {
|
|
40
|
-
this._callOnFinishChange();
|
|
41
|
-
} );
|
|
42
|
-
|
|
43
|
-
this.$text.addEventListener( 'input', () => {
|
|
44
|
-
const tryParse = normalizeColorString( this.$text.value );
|
|
45
|
-
if ( tryParse ) {
|
|
46
|
-
this._setValueFromHexString( tryParse );
|
|
47
|
-
}
|
|
48
|
-
} );
|
|
49
|
-
|
|
50
|
-
this.$text.addEventListener( 'focus', () => {
|
|
51
|
-
this._textFocused = true;
|
|
52
|
-
this.$text.select();
|
|
53
|
-
} );
|
|
54
|
-
|
|
55
|
-
this.$text.addEventListener( 'blur', () => {
|
|
56
|
-
this._textFocused = false;
|
|
57
|
-
this.updateDisplay();
|
|
58
|
-
this._callOnFinishChange();
|
|
59
|
-
} );
|
|
60
|
-
|
|
61
|
-
this.$disable = this.$text;
|
|
62
|
-
|
|
63
|
-
this.updateDisplay();
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
reset() {
|
|
68
|
-
this._setValueFromHexString( this._initialValueHexString );
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
_setValueFromHexString( value ) {
|
|
73
|
-
|
|
74
|
-
if ( this._format.isPrimitive ) {
|
|
75
|
-
|
|
76
|
-
const newValue = this._format.fromHexString( value );
|
|
77
|
-
this.setValue( newValue );
|
|
78
|
-
|
|
79
|
-
} else {
|
|
80
|
-
|
|
81
|
-
this._format.fromHexString( value, this.getValue(), this._rgbScale );
|
|
82
|
-
this._callOnChange();
|
|
83
|
-
this.updateDisplay();
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
save() {
|
|
90
|
-
return this._format.toHexString( this.getValue(), this._rgbScale );
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
load( value ) {
|
|
94
|
-
this._setValueFromHexString( value );
|
|
95
|
-
this._callOnFinishChange();
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
updateDisplay() {
|
|
100
|
-
this.$input.value = this._format.toHexString( this.getValue(), this._rgbScale );
|
|
101
|
-
if ( !this._textFocused ) {
|
|
102
|
-
this.$text.value = this.$input.value.substring( 1 );
|
|
103
|
-
}
|
|
104
|
-
this.$display.style.backgroundColor = this.$input.value;
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
}
|