spoint 0.1.0 → 0.1.10
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/README.md +134 -209
- package/SKILL.md +95 -0
- package/apps/environment/index.js +200 -1
- package/apps/environment/models/decorative/.gitkeep +0 -0
- package/apps/environment/models/hazards/.gitkeep +0 -0
- package/apps/environment/models/interactive/.gitkeep +0 -0
- package/apps/environment/models/structures/.gitkeep +0 -0
- package/apps/environment/smartObjects.js +114 -0
- package/apps/interactable/index.js +155 -0
- package/apps/physics-crate/index.js +15 -9
- package/apps/power-crate/index.js +18 -12
- package/apps/tps-game/$GDUPI.vrm +0 -0
- package/apps/tps-game/Cleetus.vrm +0 -0
- package/apps/tps-game/index.js +185 -27
- package/apps/world/index.js +68 -22
- package/bin/create-app.js +337 -0
- package/client/ARControls.js +301 -0
- package/client/LoadingManager.js +117 -0
- package/client/MobileControls.js +1122 -0
- package/client/anim-lib.glb +0 -0
- package/client/animation.js +306 -0
- package/client/app.js +1341 -65
- package/client/camera.js +191 -33
- package/client/createLoadingScreen.js +69 -0
- package/client/editor/bridge.js +113 -0
- package/client/editor/css/main.css +794 -0
- package/client/editor/images/rotate.svg +4 -0
- package/client/editor/images/scale.svg +4 -0
- package/client/editor/images/translate.svg +4 -0
- package/client/editor/index.html +103 -0
- package/client/editor/js/Command.js +41 -0
- package/client/editor/js/Config.js +81 -0
- package/client/editor/js/Editor.js +785 -0
- package/client/editor/js/EditorControls.js +438 -0
- package/client/editor/js/History.js +321 -0
- package/client/editor/js/Loader.js +987 -0
- package/client/editor/js/LoaderUtils.js +90 -0
- package/client/editor/js/Menubar.Add.js +510 -0
- package/client/editor/js/Menubar.Edit.js +145 -0
- package/client/editor/js/Menubar.File.js +466 -0
- package/client/editor/js/Menubar.Help.js +73 -0
- package/client/editor/js/Menubar.Status.js +51 -0
- package/client/editor/js/Menubar.View.js +183 -0
- package/client/editor/js/Menubar.js +27 -0
- package/client/editor/js/Player.js +53 -0
- package/client/editor/js/Resizer.js +58 -0
- package/client/editor/js/Script.js +503 -0
- package/client/editor/js/Selector.js +102 -0
- package/client/editor/js/Sidebar.Geometry.BoxGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.BufferGeometry.js +115 -0
- package/client/editor/js/Sidebar.Geometry.CapsuleGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.CircleGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.CylinderGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.DodecahedronGeometry.js +73 -0
- package/client/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +196 -0
- package/client/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +73 -0
- package/client/editor/js/Sidebar.Geometry.LatheGeometry.js +98 -0
- package/client/editor/js/Sidebar.Geometry.Modifiers.js +73 -0
- package/client/editor/js/Sidebar.Geometry.OctahedronGeometry.js +74 -0
- package/client/editor/js/Sidebar.Geometry.PlaneGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.RingGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.ShapeGeometry.js +76 -0
- package/client/editor/js/Sidebar.Geometry.SphereGeometry.js +133 -0
- package/client/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +74 -0
- package/client/editor/js/Sidebar.Geometry.TorusGeometry.js +109 -0
- package/client/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.TubeGeometry.js +135 -0
- package/client/editor/js/Sidebar.Geometry.js +332 -0
- package/client/editor/js/Sidebar.Material.BooleanProperty.js +60 -0
- package/client/editor/js/Sidebar.Material.ColorProperty.js +87 -0
- package/client/editor/js/Sidebar.Material.ConstantProperty.js +62 -0
- package/client/editor/js/Sidebar.Material.MapProperty.js +249 -0
- package/client/editor/js/Sidebar.Material.NumberProperty.js +60 -0
- package/client/editor/js/Sidebar.Material.Program.js +73 -0
- package/client/editor/js/Sidebar.Material.RangeValueProperty.js +63 -0
- package/client/editor/js/Sidebar.Material.js +751 -0
- package/client/editor/js/Sidebar.Object.Animation.js +102 -0
- package/client/editor/js/Sidebar.Object.js +898 -0
- package/client/editor/js/Sidebar.Project.App.js +165 -0
- package/client/editor/js/Sidebar.Project.Image.js +225 -0
- package/client/editor/js/Sidebar.Project.Materials.js +82 -0
- package/client/editor/js/Sidebar.Project.Renderer.js +144 -0
- package/client/editor/js/Sidebar.Project.Video.js +242 -0
- package/client/editor/js/Sidebar.Project.js +31 -0
- package/client/editor/js/Sidebar.Properties.js +73 -0
- package/client/editor/js/Sidebar.Scene.js +585 -0
- package/client/editor/js/Sidebar.Script.js +129 -0
- package/client/editor/js/Sidebar.Settings.History.js +146 -0
- package/client/editor/js/Sidebar.Settings.Shortcuts.js +175 -0
- package/client/editor/js/Sidebar.Settings.js +60 -0
- package/client/editor/js/Sidebar.js +41 -0
- package/client/editor/js/Storage.js +98 -0
- package/client/editor/js/Strings.js +2028 -0
- package/client/editor/js/Toolbar.js +84 -0
- package/client/editor/js/Viewport.Controls.js +92 -0
- package/client/editor/js/Viewport.Info.js +136 -0
- package/client/editor/js/Viewport.Pathtracer.js +91 -0
- package/client/editor/js/Viewport.ViewHelper.js +39 -0
- package/client/editor/js/Viewport.XR.js +222 -0
- package/client/editor/js/Viewport.js +900 -0
- package/client/editor/js/commands/AddObjectCommand.js +68 -0
- package/client/editor/js/commands/AddScriptCommand.js +75 -0
- package/client/editor/js/commands/Commands.js +23 -0
- package/client/editor/js/commands/MoveObjectCommand.js +111 -0
- package/client/editor/js/commands/MultiCmdsCommand.js +85 -0
- package/client/editor/js/commands/RemoveObjectCommand.js +88 -0
- package/client/editor/js/commands/RemoveScriptCommand.js +81 -0
- package/client/editor/js/commands/SetColorCommand.js +73 -0
- package/client/editor/js/commands/SetGeometryCommand.js +87 -0
- package/client/editor/js/commands/SetGeometryValueCommand.js +70 -0
- package/client/editor/js/commands/SetMaterialColorCommand.js +86 -0
- package/client/editor/js/commands/SetMaterialCommand.js +79 -0
- package/client/editor/js/commands/SetMaterialMapCommand.js +143 -0
- package/client/editor/js/commands/SetMaterialRangeCommand.js +91 -0
- package/client/editor/js/commands/SetMaterialValueCommand.js +90 -0
- package/client/editor/js/commands/SetMaterialVectorCommand.js +79 -0
- package/client/editor/js/commands/SetPositionCommand.js +84 -0
- package/client/editor/js/commands/SetRotationCommand.js +84 -0
- package/client/editor/js/commands/SetScaleCommand.js +84 -0
- package/client/editor/js/commands/SetSceneCommand.js +103 -0
- package/client/editor/js/commands/SetScriptValueCommand.js +80 -0
- package/client/editor/js/commands/SetShadowValueCommand.js +73 -0
- package/client/editor/js/commands/SetUuidCommand.js +70 -0
- package/client/editor/js/commands/SetValueCommand.js +75 -0
- package/client/editor/js/libs/acorn/acorn.js +3236 -0
- package/client/editor/js/libs/acorn/acorn_loose.js +1299 -0
- package/client/editor/js/libs/acorn/walk.js +344 -0
- package/client/editor/js/libs/app/index.html +57 -0
- package/client/editor/js/libs/app.js +251 -0
- package/client/editor/js/libs/codemirror/addon/dialog.css +32 -0
- package/client/editor/js/libs/codemirror/addon/dialog.js +163 -0
- package/client/editor/js/libs/codemirror/addon/show-hint.css +36 -0
- package/client/editor/js/libs/codemirror/addon/show-hint.js +529 -0
- package/client/editor/js/libs/codemirror/addon/tern.css +87 -0
- package/client/editor/js/libs/codemirror/addon/tern.js +750 -0
- package/client/editor/js/libs/codemirror/codemirror.css +344 -0
- package/client/editor/js/libs/codemirror/codemirror.js +9849 -0
- package/client/editor/js/libs/codemirror/mode/glsl.js +233 -0
- package/client/editor/js/libs/codemirror/mode/javascript.js +959 -0
- package/client/editor/js/libs/codemirror/theme/monokai.css +41 -0
- package/client/editor/js/libs/esprima.js +6401 -0
- package/client/editor/js/libs/jsonlint.js +453 -0
- package/client/editor/js/libs/signals.min.js +14 -0
- package/client/editor/js/libs/tern-threejs/threejs.js +5031 -0
- package/client/editor/js/libs/ternjs/comment.js +87 -0
- package/client/editor/js/libs/ternjs/def.js +588 -0
- package/client/editor/js/libs/ternjs/doc_comment.js +401 -0
- package/client/editor/js/libs/ternjs/infer.js +1635 -0
- package/client/editor/js/libs/ternjs/polyfill.js +80 -0
- package/client/editor/js/libs/ternjs/signal.js +26 -0
- package/client/editor/js/libs/ternjs/tern.js +993 -0
- package/client/editor/js/libs/ui.js +1346 -0
- package/client/editor/js/libs/ui.three.js +855 -0
- package/client/facial-animation.js +455 -0
- package/client/index.html +7 -4
- package/client/loading.css +147 -0
- package/client/loading.html +25 -0
- package/client/style.css +251 -0
- package/package.json +7 -3
- package/server.js +9 -1
- package/src/apps/AppContext.js +1 -1
- package/src/apps/AppLoader.js +50 -37
- package/src/apps/AppRuntime.js +32 -8
- package/src/client/InputHandler.js +233 -0
- package/src/client/JitterBuffer.js +207 -0
- package/src/client/KalmanFilter.js +125 -0
- package/src/client/MessageHandler.js +101 -0
- package/src/client/PhysicsNetworkClient.js +141 -68
- package/src/client/ReconnectManager.js +62 -0
- package/src/client/SmoothInterpolation.js +127 -0
- package/src/client/SnapshotProcessor.js +144 -0
- package/src/connection/ConnectionManager.js +21 -3
- package/src/connection/SessionStore.js +13 -3
- package/src/index.client.js +4 -6
- package/src/netcode/EventLog.js +29 -15
- package/src/netcode/LagCompensator.js +25 -26
- package/src/netcode/NetworkState.js +4 -1
- package/src/netcode/PhysicsIntegration.js +20 -6
- package/src/netcode/PlayerManager.js +10 -2
- package/src/netcode/SnapshotEncoder.js +66 -19
- package/src/netcode/TickSystem.js +13 -4
- package/src/physics/World.js +66 -13
- package/src/protocol/msgpack.js +90 -63
- package/src/sdk/ReloadHandlers.js +12 -2
- package/src/sdk/ReloadManager.js +5 -0
- package/src/sdk/ServerHandlers.js +50 -11
- package/src/sdk/StaticHandler.js +22 -6
- package/src/sdk/TickHandler.js +101 -34
- package/src/sdk/scaffold.js +28 -0
- package/src/sdk/server.js +59 -33
- package/src/shared/movement.js +2 -1
- package/src/spatial/Octree.js +5 -0
- package/apps/interactive-door/index.js +0 -33
- package/apps/patrol-npc/index.js +0 -37
- package/src/connection/QualityMonitor.js +0 -46
- package/src/debug/StateInspector.js +0 -42
- package/src/index.js +0 -1
- package/src/index.server.js +0 -27
- package/src/protocol/Codec.js +0 -60
- package/src/protocol/SequenceTracker.js +0 -71
- package/src/sdk/ClientMessageHandler.js +0 -80
- package/src/sdk/client.js +0 -122
- package/world/kaira.glb +0 -0
- package/world/schwust.glb +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param editor Editor
|
|
5
|
+
* @param object THREE.Object3D
|
|
6
|
+
* @param attributeName string
|
|
7
|
+
* @param newValue number, string, boolean or object
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
class SetGeometryValueCommand extends Command {
|
|
11
|
+
|
|
12
|
+
constructor( editor, object = null, attributeName = '', newValue = null ) {
|
|
13
|
+
|
|
14
|
+
super( editor );
|
|
15
|
+
|
|
16
|
+
this.type = 'SetGeometryValueCommand';
|
|
17
|
+
this.name = editor.strings.getKey( 'command/SetGeometryValue' ) + ': ' + attributeName;
|
|
18
|
+
|
|
19
|
+
this.object = object;
|
|
20
|
+
this.attributeName = attributeName;
|
|
21
|
+
this.oldValue = ( object !== null ) ? object.geometry[ attributeName ] : null;
|
|
22
|
+
this.newValue = newValue;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
execute() {
|
|
27
|
+
|
|
28
|
+
this.object.geometry[ this.attributeName ] = this.newValue;
|
|
29
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
30
|
+
this.editor.signals.geometryChanged.dispatch();
|
|
31
|
+
this.editor.signals.sceneGraphChanged.dispatch();
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
undo() {
|
|
36
|
+
|
|
37
|
+
this.object.geometry[ this.attributeName ] = this.oldValue;
|
|
38
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
39
|
+
this.editor.signals.geometryChanged.dispatch();
|
|
40
|
+
this.editor.signals.sceneGraphChanged.dispatch();
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
toJSON() {
|
|
45
|
+
|
|
46
|
+
const output = super.toJSON( this );
|
|
47
|
+
|
|
48
|
+
output.objectUuid = this.object.uuid;
|
|
49
|
+
output.attributeName = this.attributeName;
|
|
50
|
+
output.oldValue = this.oldValue;
|
|
51
|
+
output.newValue = this.newValue;
|
|
52
|
+
|
|
53
|
+
return output;
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fromJSON( json ) {
|
|
58
|
+
|
|
59
|
+
super.fromJSON( json );
|
|
60
|
+
|
|
61
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
62
|
+
this.attributeName = json.attributeName;
|
|
63
|
+
this.oldValue = json.oldValue;
|
|
64
|
+
this.newValue = json.newValue;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { SetGeometryValueCommand };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param editor Editor
|
|
5
|
+
* @param object THREE.Object3D
|
|
6
|
+
* @param attributeName string
|
|
7
|
+
* @param newValue integer representing a hex color value
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
class SetMaterialColorCommand extends Command {
|
|
11
|
+
|
|
12
|
+
constructor( editor, object = null, attributeName = '', newValue = null, materialSlot = - 1 ) {
|
|
13
|
+
|
|
14
|
+
super( editor );
|
|
15
|
+
|
|
16
|
+
this.type = 'SetMaterialColorCommand';
|
|
17
|
+
this.name = editor.strings.getKey( 'command/SetMaterialColor' ) + ': ' + attributeName;
|
|
18
|
+
this.updatable = true;
|
|
19
|
+
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.materialSlot = materialSlot;
|
|
22
|
+
|
|
23
|
+
const material = ( object !== null ) ? editor.getObjectMaterial( object, materialSlot ) : null;
|
|
24
|
+
|
|
25
|
+
this.oldValue = ( material !== null ) ? material[ attributeName ].getHex() : null;
|
|
26
|
+
this.newValue = newValue;
|
|
27
|
+
|
|
28
|
+
this.attributeName = attributeName;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
execute() {
|
|
33
|
+
|
|
34
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
35
|
+
|
|
36
|
+
material[ this.attributeName ].setHex( this.newValue );
|
|
37
|
+
|
|
38
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
undo() {
|
|
43
|
+
|
|
44
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
45
|
+
|
|
46
|
+
material[ this.attributeName ].setHex( this.oldValue );
|
|
47
|
+
|
|
48
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update( cmd ) {
|
|
53
|
+
|
|
54
|
+
this.newValue = cmd.newValue;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
toJSON() {
|
|
59
|
+
|
|
60
|
+
const output = super.toJSON( this );
|
|
61
|
+
|
|
62
|
+
output.objectUuid = this.object.uuid;
|
|
63
|
+
output.attributeName = this.attributeName;
|
|
64
|
+
output.oldValue = this.oldValue;
|
|
65
|
+
output.newValue = this.newValue;
|
|
66
|
+
output.materialSlot = this.materialSlot;
|
|
67
|
+
|
|
68
|
+
return output;
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fromJSON( json ) {
|
|
73
|
+
|
|
74
|
+
super.fromJSON( json );
|
|
75
|
+
|
|
76
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
77
|
+
this.attributeName = json.attributeName;
|
|
78
|
+
this.oldValue = json.oldValue;
|
|
79
|
+
this.newValue = json.newValue;
|
|
80
|
+
this.materialSlot = json.materialSlot;
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { SetMaterialColorCommand };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
import { ObjectLoader } from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param editor Editor
|
|
6
|
+
* @param object THREE.Object3D
|
|
7
|
+
* @param newMaterial THREE.Material
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
class SetMaterialCommand extends Command {
|
|
11
|
+
|
|
12
|
+
constructor( editor, object = null, newMaterial = null, materialSlot = - 1 ) {
|
|
13
|
+
|
|
14
|
+
super( editor );
|
|
15
|
+
|
|
16
|
+
this.type = 'SetMaterialCommand';
|
|
17
|
+
this.name = editor.strings.getKey( 'command/SetMaterial' );
|
|
18
|
+
|
|
19
|
+
this.object = object;
|
|
20
|
+
this.materialSlot = materialSlot;
|
|
21
|
+
|
|
22
|
+
this.oldMaterial = ( object !== null ) ? editor.getObjectMaterial( object, materialSlot ) : null;
|
|
23
|
+
this.newMaterial = newMaterial;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
execute() {
|
|
28
|
+
|
|
29
|
+
this.editor.setObjectMaterial( this.object, this.materialSlot, this.newMaterial );
|
|
30
|
+
|
|
31
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
undo() {
|
|
36
|
+
|
|
37
|
+
this.editor.setObjectMaterial( this.object, this.materialSlot, this.oldMaterial );
|
|
38
|
+
|
|
39
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toJSON() {
|
|
44
|
+
|
|
45
|
+
const output = super.toJSON( this );
|
|
46
|
+
|
|
47
|
+
output.objectUuid = this.object.uuid;
|
|
48
|
+
output.oldMaterial = this.oldMaterial.toJSON();
|
|
49
|
+
output.newMaterial = this.newMaterial.toJSON();
|
|
50
|
+
output.materialSlot = this.materialSlot;
|
|
51
|
+
|
|
52
|
+
return output;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fromJSON( json ) {
|
|
57
|
+
|
|
58
|
+
super.fromJSON( json );
|
|
59
|
+
|
|
60
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
61
|
+
this.oldMaterial = parseMaterial( json.oldMaterial );
|
|
62
|
+
this.newMaterial = parseMaterial( json.newMaterial );
|
|
63
|
+
this.materialSlot = json.materialSlot;
|
|
64
|
+
|
|
65
|
+
function parseMaterial( json ) {
|
|
66
|
+
|
|
67
|
+
const loader = new ObjectLoader();
|
|
68
|
+
const images = loader.parseImages( json.images );
|
|
69
|
+
const textures = loader.parseTextures( json.textures, images );
|
|
70
|
+
const materials = loader.parseMaterials( [ json ], textures );
|
|
71
|
+
return materials[ json.uuid ];
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { SetMaterialCommand };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
import { ObjectLoader } from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param editor Editor
|
|
6
|
+
* @param object THREE.Object3D
|
|
7
|
+
* @param mapName string
|
|
8
|
+
* @param newMap THREE.Texture
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetMaterialMapCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, object = null, mapName = '', newMap = null, materialSlot = - 1 ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetMaterialMapCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetMaterialMap' ) + ': ' + mapName;
|
|
19
|
+
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.materialSlot = materialSlot;
|
|
22
|
+
|
|
23
|
+
const material = ( object !== null ) ? editor.getObjectMaterial( object, materialSlot ) : null;
|
|
24
|
+
|
|
25
|
+
this.oldMap = ( object !== null ) ? material[ mapName ] : undefined;
|
|
26
|
+
this.newMap = newMap;
|
|
27
|
+
|
|
28
|
+
this.mapName = mapName;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
execute() {
|
|
33
|
+
|
|
34
|
+
if ( this.oldMap !== null && this.oldMap !== undefined ) this.oldMap.dispose();
|
|
35
|
+
|
|
36
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
37
|
+
|
|
38
|
+
material[ this.mapName ] = this.newMap;
|
|
39
|
+
material.needsUpdate = true;
|
|
40
|
+
|
|
41
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
undo() {
|
|
46
|
+
|
|
47
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
48
|
+
|
|
49
|
+
material[ this.mapName ] = this.oldMap;
|
|
50
|
+
material.needsUpdate = true;
|
|
51
|
+
|
|
52
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
toJSON() {
|
|
57
|
+
|
|
58
|
+
const output = super.toJSON( this );
|
|
59
|
+
|
|
60
|
+
output.objectUuid = this.object.uuid;
|
|
61
|
+
output.mapName = this.mapName;
|
|
62
|
+
output.newMap = serializeMap( this.newMap );
|
|
63
|
+
output.oldMap = serializeMap( this.oldMap );
|
|
64
|
+
output.materialSlot = this.materialSlot;
|
|
65
|
+
|
|
66
|
+
return output;
|
|
67
|
+
|
|
68
|
+
// serializes a map (THREE.Texture)
|
|
69
|
+
|
|
70
|
+
function serializeMap( map ) {
|
|
71
|
+
|
|
72
|
+
if ( map === null || map === undefined ) return null;
|
|
73
|
+
|
|
74
|
+
const meta = {
|
|
75
|
+
geometries: {},
|
|
76
|
+
materials: {},
|
|
77
|
+
textures: {},
|
|
78
|
+
images: {}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const json = map.toJSON( meta );
|
|
82
|
+
const images = extractFromCache( meta.images );
|
|
83
|
+
if ( images.length > 0 ) json.images = images;
|
|
84
|
+
json.sourceFile = map.sourceFile;
|
|
85
|
+
|
|
86
|
+
return json;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Note: The function 'extractFromCache' is copied from Object3D.toJSON()
|
|
91
|
+
|
|
92
|
+
// extract data from the cache hash
|
|
93
|
+
// remove metadata on each item
|
|
94
|
+
// and return as array
|
|
95
|
+
function extractFromCache( cache ) {
|
|
96
|
+
|
|
97
|
+
const values = [];
|
|
98
|
+
for ( const key in cache ) {
|
|
99
|
+
|
|
100
|
+
const data = cache[ key ];
|
|
101
|
+
delete data.metadata;
|
|
102
|
+
values.push( data );
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return values;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fromJSON( json ) {
|
|
113
|
+
|
|
114
|
+
super.fromJSON( json );
|
|
115
|
+
|
|
116
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
117
|
+
this.mapName = json.mapName;
|
|
118
|
+
this.oldMap = parseTexture( json.oldMap );
|
|
119
|
+
this.newMap = parseTexture( json.newMap );
|
|
120
|
+
this.materialSlot = json.materialSlot;
|
|
121
|
+
|
|
122
|
+
function parseTexture( json ) {
|
|
123
|
+
|
|
124
|
+
let map = null;
|
|
125
|
+
if ( json !== null ) {
|
|
126
|
+
|
|
127
|
+
const loader = new ObjectLoader();
|
|
128
|
+
const images = loader.parseImages( json.images );
|
|
129
|
+
const textures = loader.parseTextures( [ json ], images );
|
|
130
|
+
map = textures[ json.uuid ];
|
|
131
|
+
map.sourceFile = json.sourceFile;
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return map;
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { SetMaterialMapCommand };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param editor Editor
|
|
5
|
+
* @param object THREE.Object3D
|
|
6
|
+
* @param attributeName string
|
|
7
|
+
* @param newMinValue number
|
|
8
|
+
* @param newMaxValue number
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetMaterialRangeCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, object = null, attributeName = '', newMinValue = - Infinity, newMaxValue = Infinity, materialSlot = - 1 ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetMaterialRangeCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetMaterialRange' ) + ': ' + attributeName;
|
|
19
|
+
this.updatable = true;
|
|
20
|
+
|
|
21
|
+
this.object = object;
|
|
22
|
+
this.materialSlot = materialSlot;
|
|
23
|
+
|
|
24
|
+
const material = ( object !== null ) ? editor.getObjectMaterial( object, materialSlot ) : null;
|
|
25
|
+
|
|
26
|
+
this.oldRange = ( material !== null && material[ attributeName ] !== undefined ) ? [ ...this.material[ attributeName ] ] : null;
|
|
27
|
+
this.newRange = [ newMinValue, newMaxValue ];
|
|
28
|
+
|
|
29
|
+
this.attributeName = attributeName;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
execute() {
|
|
34
|
+
|
|
35
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
36
|
+
|
|
37
|
+
material[ this.attributeName ] = [ ...this.newRange ];
|
|
38
|
+
material.needsUpdate = true;
|
|
39
|
+
|
|
40
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
41
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
undo() {
|
|
46
|
+
|
|
47
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
48
|
+
|
|
49
|
+
material[ this.attributeName ] = [ ...this.oldRange ];
|
|
50
|
+
material.needsUpdate = true;
|
|
51
|
+
|
|
52
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
53
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
update( cmd ) {
|
|
58
|
+
|
|
59
|
+
this.newRange = [ ...cmd.newRange ];
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
toJSON() {
|
|
64
|
+
|
|
65
|
+
const output = super.toJSON( this );
|
|
66
|
+
|
|
67
|
+
output.objectUuid = this.object.uuid;
|
|
68
|
+
output.attributeName = this.attributeName;
|
|
69
|
+
output.oldRange = [ ...this.oldRange ];
|
|
70
|
+
output.newRange = [ ...this.newRange ];
|
|
71
|
+
output.materialSlot = this.materialSlot;
|
|
72
|
+
|
|
73
|
+
return output;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fromJSON( json ) {
|
|
78
|
+
|
|
79
|
+
super.fromJSON( json );
|
|
80
|
+
|
|
81
|
+
this.attributeName = json.attributeName;
|
|
82
|
+
this.oldRange = [ ...json.oldRange ];
|
|
83
|
+
this.newRange = [ ...json.newRange ];
|
|
84
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
85
|
+
this.materialSlot = json.materialSlot;
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { SetMaterialRangeCommand };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param editor Editor
|
|
5
|
+
* @param object THREE.Object3D
|
|
6
|
+
* @param attributeName string
|
|
7
|
+
* @param newValue number, string, boolean or object
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
class SetMaterialValueCommand extends Command {
|
|
11
|
+
|
|
12
|
+
constructor( editor, object = null, attributeName = '', newValue = null, materialSlot = - 1 ) {
|
|
13
|
+
|
|
14
|
+
super( editor );
|
|
15
|
+
|
|
16
|
+
this.type = 'SetMaterialValueCommand';
|
|
17
|
+
this.name = editor.strings.getKey( 'command/SetMaterialValue' ) + ': ' + attributeName;
|
|
18
|
+
this.updatable = true;
|
|
19
|
+
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.materialSlot = materialSlot;
|
|
22
|
+
|
|
23
|
+
const material = ( object !== null ) ? editor.getObjectMaterial( object, materialSlot ) : null;
|
|
24
|
+
|
|
25
|
+
this.oldValue = ( material !== null ) ? material[ attributeName ] : null;
|
|
26
|
+
this.newValue = newValue;
|
|
27
|
+
|
|
28
|
+
this.attributeName = attributeName;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
execute() {
|
|
33
|
+
|
|
34
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
35
|
+
|
|
36
|
+
material[ this.attributeName ] = this.newValue;
|
|
37
|
+
material.needsUpdate = true;
|
|
38
|
+
|
|
39
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
40
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
undo() {
|
|
45
|
+
|
|
46
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
47
|
+
|
|
48
|
+
material[ this.attributeName ] = this.oldValue;
|
|
49
|
+
material.needsUpdate = true;
|
|
50
|
+
|
|
51
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
52
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
update( cmd ) {
|
|
57
|
+
|
|
58
|
+
this.newValue = cmd.newValue;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
toJSON() {
|
|
63
|
+
|
|
64
|
+
const output = super.toJSON( this );
|
|
65
|
+
|
|
66
|
+
output.objectUuid = this.object.uuid;
|
|
67
|
+
output.attributeName = this.attributeName;
|
|
68
|
+
output.oldValue = this.oldValue;
|
|
69
|
+
output.newValue = this.newValue;
|
|
70
|
+
output.materialSlot = this.materialSlot;
|
|
71
|
+
|
|
72
|
+
return output;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fromJSON( json ) {
|
|
77
|
+
|
|
78
|
+
super.fromJSON( json );
|
|
79
|
+
|
|
80
|
+
this.attributeName = json.attributeName;
|
|
81
|
+
this.oldValue = json.oldValue;
|
|
82
|
+
this.newValue = json.newValue;
|
|
83
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
84
|
+
this.materialSlot = json.materialSlot;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { SetMaterialValueCommand };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
class SetMaterialVectorCommand extends Command {
|
|
4
|
+
|
|
5
|
+
constructor( editor, object = null, attributeName = '', newValue = null, materialSlot = - 1 ) {
|
|
6
|
+
|
|
7
|
+
super( editor );
|
|
8
|
+
|
|
9
|
+
this.type = 'SetMaterialVectorCommand';
|
|
10
|
+
this.name = editor.strings.getKey( 'command/SetMaterialVector' ) + ': ' + attributeName;
|
|
11
|
+
this.updatable = true;
|
|
12
|
+
|
|
13
|
+
this.object = object;
|
|
14
|
+
this.materialSlot = materialSlot;
|
|
15
|
+
|
|
16
|
+
const material = ( object !== null ) ? editor.getObjectMaterial( object, materialSlot ) : null;
|
|
17
|
+
|
|
18
|
+
this.oldValue = ( material !== null ) ? material[ attributeName ].toArray() : null;
|
|
19
|
+
this.newValue = newValue;
|
|
20
|
+
|
|
21
|
+
this.attributeName = attributeName;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
execute() {
|
|
26
|
+
|
|
27
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
28
|
+
|
|
29
|
+
material[ this.attributeName ].fromArray( this.newValue );
|
|
30
|
+
|
|
31
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
undo() {
|
|
36
|
+
|
|
37
|
+
const material = this.editor.getObjectMaterial( this.object, this.materialSlot );
|
|
38
|
+
|
|
39
|
+
material[ this.attributeName ].fromArray( this.oldValue );
|
|
40
|
+
|
|
41
|
+
this.editor.signals.materialChanged.dispatch( this.object, this.materialSlot );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
update( cmd ) {
|
|
46
|
+
|
|
47
|
+
this.newValue = cmd.newValue;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
toJSON() {
|
|
52
|
+
|
|
53
|
+
const output = super.toJSON( this );
|
|
54
|
+
|
|
55
|
+
output.objectUuid = this.object.uuid;
|
|
56
|
+
output.attributeName = this.attributeName;
|
|
57
|
+
output.oldValue = this.oldValue;
|
|
58
|
+
output.newValue = this.newValue;
|
|
59
|
+
output.materialSlot = this.materialSlot;
|
|
60
|
+
|
|
61
|
+
return output;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fromJSON( json ) {
|
|
66
|
+
|
|
67
|
+
super.fromJSON( json );
|
|
68
|
+
|
|
69
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
70
|
+
this.attributeName = json.attributeName;
|
|
71
|
+
this.oldValue = json.oldValue;
|
|
72
|
+
this.newValue = json.newValue;
|
|
73
|
+
this.materialSlot = json.materialSlot;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { SetMaterialVectorCommand };
|