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,84 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param editor Editor
|
|
6
|
+
* @param object THREE.Object3D
|
|
7
|
+
* @param newPosition THREE.Vector3
|
|
8
|
+
* @param optionalOldPosition THREE.Vector3
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetPositionCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, object = null, newPosition = null, optionalOldPosition = null ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetPositionCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetPosition' );
|
|
19
|
+
this.updatable = true;
|
|
20
|
+
|
|
21
|
+
this.object = object;
|
|
22
|
+
|
|
23
|
+
if ( object !== null && newPosition !== null ) {
|
|
24
|
+
|
|
25
|
+
this.oldPosition = object.position.clone();
|
|
26
|
+
this.newPosition = newPosition.clone();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ( optionalOldPosition !== null ) {
|
|
31
|
+
|
|
32
|
+
this.oldPosition = optionalOldPosition.clone();
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
execute() {
|
|
39
|
+
|
|
40
|
+
this.object.position.copy( this.newPosition );
|
|
41
|
+
this.object.updateMatrixWorld( true );
|
|
42
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
undo() {
|
|
47
|
+
|
|
48
|
+
this.object.position.copy( this.oldPosition );
|
|
49
|
+
this.object.updateMatrixWorld( true );
|
|
50
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
update( command ) {
|
|
55
|
+
|
|
56
|
+
this.newPosition.copy( command.newPosition );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
toJSON() {
|
|
61
|
+
|
|
62
|
+
const output = super.toJSON( this );
|
|
63
|
+
|
|
64
|
+
output.objectUuid = this.object.uuid;
|
|
65
|
+
output.oldPosition = this.oldPosition.toArray();
|
|
66
|
+
output.newPosition = this.newPosition.toArray();
|
|
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.oldPosition = new Vector3().fromArray( json.oldPosition );
|
|
78
|
+
this.newPosition = new Vector3().fromArray( json.newPosition );
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { SetPositionCommand };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
import { Euler } from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param editor Editor
|
|
6
|
+
* @param object THREE.Object3D
|
|
7
|
+
* @param newRotation THREE.Euler
|
|
8
|
+
* @param optionalOldRotation THREE.Euler
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetRotationCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, object = null, newRotation = null, optionalOldRotation = null ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetRotationCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetRotation' );
|
|
19
|
+
this.updatable = true;
|
|
20
|
+
|
|
21
|
+
this.object = object;
|
|
22
|
+
|
|
23
|
+
if ( object !== null && newRotation !== null ) {
|
|
24
|
+
|
|
25
|
+
this.oldRotation = object.rotation.clone();
|
|
26
|
+
this.newRotation = newRotation.clone();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ( optionalOldRotation !== null ) {
|
|
31
|
+
|
|
32
|
+
this.oldRotation = optionalOldRotation.clone();
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
execute() {
|
|
39
|
+
|
|
40
|
+
this.object.rotation.copy( this.newRotation );
|
|
41
|
+
this.object.updateMatrixWorld( true );
|
|
42
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
undo() {
|
|
47
|
+
|
|
48
|
+
this.object.rotation.copy( this.oldRotation );
|
|
49
|
+
this.object.updateMatrixWorld( true );
|
|
50
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
update( command ) {
|
|
55
|
+
|
|
56
|
+
this.newRotation.copy( command.newRotation );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
toJSON() {
|
|
61
|
+
|
|
62
|
+
const output = super.toJSON( this );
|
|
63
|
+
|
|
64
|
+
output.objectUuid = this.object.uuid;
|
|
65
|
+
output.oldRotation = this.oldRotation.toArray();
|
|
66
|
+
output.newRotation = this.newRotation.toArray();
|
|
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.oldRotation = new Euler().fromArray( json.oldRotation );
|
|
78
|
+
this.newRotation = new Euler().fromArray( json.newRotation );
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { SetRotationCommand };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param editor Editor
|
|
6
|
+
* @param object THREE.Object3D
|
|
7
|
+
* @param newScale THREE.Vector3
|
|
8
|
+
* @param optionalOldScale THREE.Vector3
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetScaleCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, object = null, newScale = null, optionalOldScale = null ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetScaleCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetScale' );
|
|
19
|
+
this.updatable = true;
|
|
20
|
+
|
|
21
|
+
this.object = object;
|
|
22
|
+
|
|
23
|
+
if ( object !== null && newScale !== null ) {
|
|
24
|
+
|
|
25
|
+
this.oldScale = object.scale.clone();
|
|
26
|
+
this.newScale = newScale.clone();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ( optionalOldScale !== null ) {
|
|
31
|
+
|
|
32
|
+
this.oldScale = optionalOldScale.clone();
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
execute() {
|
|
39
|
+
|
|
40
|
+
this.object.scale.copy( this.newScale );
|
|
41
|
+
this.object.updateMatrixWorld( true );
|
|
42
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
undo() {
|
|
47
|
+
|
|
48
|
+
this.object.scale.copy( this.oldScale );
|
|
49
|
+
this.object.updateMatrixWorld( true );
|
|
50
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
update( command ) {
|
|
55
|
+
|
|
56
|
+
this.newScale.copy( command.newScale );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
toJSON() {
|
|
61
|
+
|
|
62
|
+
const output = super.toJSON( this );
|
|
63
|
+
|
|
64
|
+
output.objectUuid = this.object.uuid;
|
|
65
|
+
output.oldScale = this.oldScale.toArray();
|
|
66
|
+
output.newScale = this.newScale.toArray();
|
|
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.oldScale = new Vector3().fromArray( json.oldScale );
|
|
78
|
+
this.newScale = new Vector3().fromArray( json.newScale );
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { SetScaleCommand };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
import { SetUuidCommand } from './SetUuidCommand.js';
|
|
3
|
+
import { SetValueCommand } from './SetValueCommand.js';
|
|
4
|
+
import { AddObjectCommand } from './AddObjectCommand.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param editor Editor
|
|
8
|
+
* @param scene containing children to import
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetSceneCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, scene = null ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetSceneCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetScene' );
|
|
19
|
+
|
|
20
|
+
this.cmdArray = [];
|
|
21
|
+
|
|
22
|
+
if ( scene !== null ) {
|
|
23
|
+
|
|
24
|
+
this.cmdArray.push( new SetUuidCommand( this.editor, this.editor.scene, scene.uuid ) );
|
|
25
|
+
this.cmdArray.push( new SetValueCommand( this.editor, this.editor.scene, 'name', scene.name ) );
|
|
26
|
+
this.cmdArray.push( new SetValueCommand( this.editor, this.editor.scene, 'userData', JSON.parse( JSON.stringify( scene.userData ) ) ) );
|
|
27
|
+
|
|
28
|
+
while ( scene.children.length > 0 ) {
|
|
29
|
+
|
|
30
|
+
const child = scene.children.pop();
|
|
31
|
+
this.cmdArray.push( new AddObjectCommand( this.editor, child ) );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
execute() {
|
|
40
|
+
|
|
41
|
+
this.editor.signals.sceneGraphChanged.active = false;
|
|
42
|
+
|
|
43
|
+
for ( let i = 0; i < this.cmdArray.length; i ++ ) {
|
|
44
|
+
|
|
45
|
+
this.cmdArray[ i ].execute();
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.editor.signals.sceneGraphChanged.active = true;
|
|
50
|
+
this.editor.signals.sceneGraphChanged.dispatch();
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
undo() {
|
|
55
|
+
|
|
56
|
+
this.editor.signals.sceneGraphChanged.active = false;
|
|
57
|
+
|
|
58
|
+
for ( let i = this.cmdArray.length - 1; i >= 0; i -- ) {
|
|
59
|
+
|
|
60
|
+
this.cmdArray[ i ].undo();
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.editor.signals.sceneGraphChanged.active = true;
|
|
65
|
+
this.editor.signals.sceneGraphChanged.dispatch();
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toJSON() {
|
|
70
|
+
|
|
71
|
+
const output = super.toJSON( this );
|
|
72
|
+
|
|
73
|
+
const cmds = [];
|
|
74
|
+
for ( let i = 0; i < this.cmdArray.length; i ++ ) {
|
|
75
|
+
|
|
76
|
+
cmds.push( this.cmdArray[ i ].toJSON() );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
output.cmds = cmds;
|
|
81
|
+
|
|
82
|
+
return output;
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fromJSON( json ) {
|
|
87
|
+
|
|
88
|
+
super.fromJSON( json );
|
|
89
|
+
|
|
90
|
+
const cmds = json.cmds;
|
|
91
|
+
for ( let i = 0; i < cmds.length; i ++ ) {
|
|
92
|
+
|
|
93
|
+
const cmd = new window[ cmds[ i ].type ](); // creates a new object of type "json.type"
|
|
94
|
+
cmd.fromJSON( cmds[ i ] );
|
|
95
|
+
this.cmdArray.push( cmd );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { SetSceneCommand };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param editor Editor
|
|
5
|
+
* @param object THREE.Object3D
|
|
6
|
+
* @param script javascript object
|
|
7
|
+
* @param attributeName string
|
|
8
|
+
* @param newValue string, object
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
class SetScriptValueCommand extends Command {
|
|
12
|
+
|
|
13
|
+
constructor( editor, object = null, script = '', attributeName = '', newValue = null ) {
|
|
14
|
+
|
|
15
|
+
super( editor );
|
|
16
|
+
|
|
17
|
+
this.type = 'SetScriptValueCommand';
|
|
18
|
+
this.name = editor.strings.getKey( 'command/SetScriptValue' ) + ': ' + attributeName;
|
|
19
|
+
this.updatable = true;
|
|
20
|
+
|
|
21
|
+
this.object = object;
|
|
22
|
+
this.script = script;
|
|
23
|
+
|
|
24
|
+
this.attributeName = attributeName;
|
|
25
|
+
this.oldValue = ( script !== '' ) ? script[ this.attributeName ] : null;
|
|
26
|
+
this.newValue = newValue;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
execute() {
|
|
31
|
+
|
|
32
|
+
this.script[ this.attributeName ] = this.newValue;
|
|
33
|
+
|
|
34
|
+
this.editor.signals.scriptChanged.dispatch( this.script );
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
undo() {
|
|
39
|
+
|
|
40
|
+
this.script[ this.attributeName ] = this.oldValue;
|
|
41
|
+
|
|
42
|
+
this.editor.signals.scriptChanged.dispatch( this.script );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
update( cmd ) {
|
|
47
|
+
|
|
48
|
+
this.newValue = cmd.newValue;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
toJSON() {
|
|
53
|
+
|
|
54
|
+
const output = super.toJSON( this );
|
|
55
|
+
|
|
56
|
+
output.objectUuid = this.object.uuid;
|
|
57
|
+
output.index = this.editor.scripts[ this.object.uuid ].indexOf( this.script );
|
|
58
|
+
output.attributeName = this.attributeName;
|
|
59
|
+
output.oldValue = this.oldValue;
|
|
60
|
+
output.newValue = this.newValue;
|
|
61
|
+
|
|
62
|
+
return output;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fromJSON( json ) {
|
|
67
|
+
|
|
68
|
+
super.fromJSON( json );
|
|
69
|
+
|
|
70
|
+
this.oldValue = json.oldValue;
|
|
71
|
+
this.newValue = json.newValue;
|
|
72
|
+
this.attributeName = json.attributeName;
|
|
73
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
74
|
+
this.script = this.editor.scripts[ json.objectUuid ][ json.index ];
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { SetScriptValueCommand };
|
|
@@ -0,0 +1,73 @@
|
|
|
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 SetShadowValueCommand extends Command {
|
|
11
|
+
|
|
12
|
+
constructor( editor, object = null, attributeName = '', newValue = null ) {
|
|
13
|
+
|
|
14
|
+
super( editor );
|
|
15
|
+
|
|
16
|
+
this.type = 'SetShadowValueCommand';
|
|
17
|
+
this.name = editor.strings.getKey( 'command/SetShadowValue' ) + ': ' + attributeName;
|
|
18
|
+
this.updatable = true;
|
|
19
|
+
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.attributeName = attributeName;
|
|
22
|
+
this.oldValue = ( object !== null ) ? object.shadow[ attributeName ] : null;
|
|
23
|
+
this.newValue = newValue;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
execute() {
|
|
28
|
+
|
|
29
|
+
this.object.shadow[ this.attributeName ] = this.newValue;
|
|
30
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
undo() {
|
|
35
|
+
|
|
36
|
+
this.object.shadow[ this.attributeName ] = this.oldValue;
|
|
37
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
update( cmd ) {
|
|
42
|
+
|
|
43
|
+
this.newValue = cmd.newValue;
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
toJSON() {
|
|
48
|
+
|
|
49
|
+
const output = super.toJSON( this );
|
|
50
|
+
|
|
51
|
+
output.objectUuid = this.object.uuid;
|
|
52
|
+
output.attributeName = this.attributeName;
|
|
53
|
+
output.oldValue = this.oldValue;
|
|
54
|
+
output.newValue = this.newValue;
|
|
55
|
+
|
|
56
|
+
return output;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fromJSON( json ) {
|
|
61
|
+
|
|
62
|
+
super.fromJSON( json );
|
|
63
|
+
|
|
64
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
65
|
+
this.attributeName = json.attributeName;
|
|
66
|
+
this.oldValue = json.oldValue;
|
|
67
|
+
this.newValue = json.newValue;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { SetShadowValueCommand };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Command } from '../Command.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param editor Editor
|
|
5
|
+
* @param object THREE.Object3D
|
|
6
|
+
* @param newUuid string
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
class SetUuidCommand extends Command {
|
|
10
|
+
|
|
11
|
+
constructor( editor, object = null, newUuid = null ) {
|
|
12
|
+
|
|
13
|
+
super( editor );
|
|
14
|
+
|
|
15
|
+
this.type = 'SetUuidCommand';
|
|
16
|
+
this.name = editor.strings.getKey( 'command/SetUuid' );
|
|
17
|
+
|
|
18
|
+
this.object = object;
|
|
19
|
+
|
|
20
|
+
this.oldUuid = ( object !== null ) ? object.uuid : null;
|
|
21
|
+
this.newUuid = newUuid;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
execute() {
|
|
26
|
+
|
|
27
|
+
this.object.uuid = this.newUuid;
|
|
28
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
29
|
+
this.editor.signals.sceneGraphChanged.dispatch();
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
undo() {
|
|
34
|
+
|
|
35
|
+
this.object.uuid = this.oldUuid;
|
|
36
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
37
|
+
this.editor.signals.sceneGraphChanged.dispatch();
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
toJSON() {
|
|
42
|
+
|
|
43
|
+
const output = super.toJSON( this );
|
|
44
|
+
|
|
45
|
+
output.oldUuid = this.oldUuid;
|
|
46
|
+
output.newUuid = this.newUuid;
|
|
47
|
+
|
|
48
|
+
return output;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fromJSON( json ) {
|
|
53
|
+
|
|
54
|
+
super.fromJSON( json );
|
|
55
|
+
|
|
56
|
+
this.oldUuid = json.oldUuid;
|
|
57
|
+
this.newUuid = json.newUuid;
|
|
58
|
+
this.object = this.editor.objectByUuid( json.oldUuid );
|
|
59
|
+
|
|
60
|
+
if ( this.object === undefined ) {
|
|
61
|
+
|
|
62
|
+
this.object = this.editor.objectByUuid( json.newUuid );
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { SetUuidCommand };
|
|
@@ -0,0 +1,75 @@
|
|
|
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 SetValueCommand extends Command {
|
|
11
|
+
|
|
12
|
+
constructor( editor, object = null, attributeName = '', newValue = null ) {
|
|
13
|
+
|
|
14
|
+
super( editor );
|
|
15
|
+
|
|
16
|
+
this.type = 'SetValueCommand';
|
|
17
|
+
this.name = editor.strings.getKey( 'command/SetValue' ) + ': ' + attributeName;
|
|
18
|
+
this.updatable = true;
|
|
19
|
+
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.attributeName = attributeName;
|
|
22
|
+
this.oldValue = ( object !== null ) ? object[ attributeName ] : null;
|
|
23
|
+
this.newValue = newValue;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
execute() {
|
|
28
|
+
|
|
29
|
+
this.object[ this.attributeName ] = this.newValue;
|
|
30
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
31
|
+
// this.editor.signals.sceneGraphChanged.dispatch();
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
undo() {
|
|
36
|
+
|
|
37
|
+
this.object[ this.attributeName ] = this.oldValue;
|
|
38
|
+
this.editor.signals.objectChanged.dispatch( this.object );
|
|
39
|
+
// this.editor.signals.sceneGraphChanged.dispatch();
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
update( cmd ) {
|
|
44
|
+
|
|
45
|
+
this.newValue = cmd.newValue;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
toJSON() {
|
|
50
|
+
|
|
51
|
+
const output = super.toJSON( this );
|
|
52
|
+
|
|
53
|
+
output.objectUuid = this.object.uuid;
|
|
54
|
+
output.attributeName = this.attributeName;
|
|
55
|
+
output.oldValue = this.oldValue;
|
|
56
|
+
output.newValue = this.newValue;
|
|
57
|
+
|
|
58
|
+
return output;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fromJSON( json ) {
|
|
63
|
+
|
|
64
|
+
super.fromJSON( json );
|
|
65
|
+
|
|
66
|
+
this.attributeName = json.attributeName;
|
|
67
|
+
this.oldValue = json.oldValue;
|
|
68
|
+
this.newValue = json.newValue;
|
|
69
|
+
this.object = this.editor.objectByUuid( json.objectUuid );
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { SetValueCommand };
|