Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
62ebe779
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
62ebe779
编写于
10月 22, 2015
作者:
D
Daniel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed commands and added folder 'commands'
上级
9841cb2b
变更
67
隐藏空白更改
内联
并排
Showing
67 changed file
with
467 addition
and
467 deletion
+467
-467
editor/docs/Implementing additional commands for undo-redo.md
...or/docs/Implementing additional commands for undo-redo.md
+13
-13
editor/docs/Writing unit tests for undo-redo commands.md
editor/docs/Writing unit tests for undo-redo commands.md
+4
-4
editor/index.html
editor/index.html
+22
-22
editor/js/Command.js
editor/js/Command.js
+5
-5
editor/js/History.js
editor/js/History.js
+4
-4
editor/js/Loader.js
editor/js/Loader.js
+20
-20
editor/js/Menubar.Add.js
editor/js/Menubar.Add.js
+16
-16
editor/js/Menubar.Edit.js
editor/js/Menubar.Edit.js
+5
-5
editor/js/Script.js
editor/js/Script.js
+4
-4
editor/js/Sidebar.Geometry.BoxGeometry.js
editor/js/Sidebar.Geometry.BoxGeometry.js
+1
-1
editor/js/Sidebar.Geometry.CircleGeometry.js
editor/js/Sidebar.Geometry.CircleGeometry.js
+1
-1
editor/js/Sidebar.Geometry.CylinderGeometry.js
editor/js/Sidebar.Geometry.CylinderGeometry.js
+1
-1
editor/js/Sidebar.Geometry.IcosahedronGeometry.js
editor/js/Sidebar.Geometry.IcosahedronGeometry.js
+1
-1
editor/js/Sidebar.Geometry.PlaneGeometry.js
editor/js/Sidebar.Geometry.PlaneGeometry.js
+1
-1
editor/js/Sidebar.Geometry.SphereGeometry.js
editor/js/Sidebar.Geometry.SphereGeometry.js
+1
-1
editor/js/Sidebar.Geometry.TorusGeometry.js
editor/js/Sidebar.Geometry.TorusGeometry.js
+1
-1
editor/js/Sidebar.Geometry.TorusKnotGeometry.js
editor/js/Sidebar.Geometry.TorusKnotGeometry.js
+1
-1
editor/js/Sidebar.Geometry.js
editor/js/Sidebar.Geometry.js
+9
-9
editor/js/Sidebar.Material.js
editor/js/Sidebar.Material.js
+30
-30
editor/js/Sidebar.Object3D.js
editor/js/Sidebar.Object3D.js
+23
-23
editor/js/Sidebar.Script.js
editor/js/Sidebar.Script.js
+3
-3
editor/js/Viewport.js
editor/js/Viewport.js
+3
-3
editor/js/commands/AddObjectCommand.js
editor/js/commands/AddObjectCommand.js
+6
-6
editor/js/commands/AddScriptCommand.js
editor/js/commands/AddScriptCommand.js
+6
-6
editor/js/commands/MoveObjectCommand.js
editor/js/commands/MoveObjectCommand.js
+6
-6
editor/js/commands/MultiCmdsCommand.js
editor/js/commands/MultiCmdsCommand.js
+6
-6
editor/js/commands/RemoveObjectCommand.js
editor/js/commands/RemoveObjectCommand.js
+6
-6
editor/js/commands/RemoveScriptCommand.js
editor/js/commands/RemoveScriptCommand.js
+6
-6
editor/js/commands/SetColorCommand.js
editor/js/commands/SetColorCommand.js
+6
-6
editor/js/commands/SetGeometryCommand.js
editor/js/commands/SetGeometryCommand.js
+6
-6
editor/js/commands/SetGeometryValueCommand.js
editor/js/commands/SetGeometryValueCommand.js
+6
-6
editor/js/commands/SetMaterialColorCommand.js
editor/js/commands/SetMaterialColorCommand.js
+6
-6
editor/js/commands/SetMaterialCommand.js
editor/js/commands/SetMaterialCommand.js
+6
-6
editor/js/commands/SetMaterialMapCommand.js
editor/js/commands/SetMaterialMapCommand.js
+6
-6
editor/js/commands/SetMaterialValueCommand.js
editor/js/commands/SetMaterialValueCommand.js
+6
-6
editor/js/commands/SetPositionCommand.js
editor/js/commands/SetPositionCommand.js
+6
-6
editor/js/commands/SetRotationCommand.js
editor/js/commands/SetRotationCommand.js
+6
-6
editor/js/commands/SetScaleCommand.js
editor/js/commands/SetScaleCommand.js
+6
-6
editor/js/commands/SetSceneCommand.js
editor/js/commands/SetSceneCommand.js
+10
-10
editor/js/commands/SetScriptValueCommand.js
editor/js/commands/SetScriptValueCommand.js
+6
-6
editor/js/commands/SetUuidCommand.js
editor/js/commands/SetUuidCommand.js
+6
-6
editor/js/commands/SetValueCommand.js
editor/js/commands/SetValueCommand.js
+6
-6
editor/js/libs/ui.three.js
editor/js/libs/ui.three.js
+2
-2
test/unit/editor/TestAddObjectCommandAndRemoveObjectCommand.js
...unit/editor/TestAddObjectCommandAndRemoveObjectCommand.js
+4
-4
test/unit/editor/TestAddScriptCommand.js
test/unit/editor/TestAddScriptCommand.js
+4
-4
test/unit/editor/TestMassUndoAndRedo.js
test/unit/editor/TestMassUndoAndRedo.js
+1
-1
test/unit/editor/TestMoveObjectCommand.js
test/unit/editor/TestMoveObjectCommand.js
+5
-5
test/unit/editor/TestMultiCmdsCommand.js
test/unit/editor/TestMultiCmdsCommand.js
+13
-13
test/unit/editor/TestNegativeCases.js
test/unit/editor/TestNegativeCases.js
+1
-1
test/unit/editor/TestNestedDoUndoRedo.js
test/unit/editor/TestNestedDoUndoRedo.js
+5
-5
test/unit/editor/TestRemoveScriptCommand.js
test/unit/editor/TestRemoveScriptCommand.js
+5
-5
test/unit/editor/TestSerialization.js
test/unit/editor/TestSerialization.js
+36
-36
test/unit/editor/TestSetColorCommand.js
test/unit/editor/TestSetColorCommand.js
+4
-4
test/unit/editor/TestSetGeometryCommand.js
test/unit/editor/TestSetGeometryCommand.js
+4
-4
test/unit/editor/TestSetGeometryValueCommand.js
test/unit/editor/TestSetGeometryValueCommand.js
+4
-4
test/unit/editor/TestSetMaterialColorCommand.js
test/unit/editor/TestSetMaterialColorCommand.js
+4
-4
test/unit/editor/TestSetMaterialCommand.js
test/unit/editor/TestSetMaterialCommand.js
+4
-4
test/unit/editor/TestSetMaterialMapCommand.js
test/unit/editor/TestSetMaterialMapCommand.js
+4
-4
test/unit/editor/TestSetMaterialValueCommand.js
test/unit/editor/TestSetMaterialValueCommand.js
+4
-4
test/unit/editor/TestSetPositionCommand.js
test/unit/editor/TestSetPositionCommand.js
+4
-4
test/unit/editor/TestSetRotationCommand.js
test/unit/editor/TestSetRotationCommand.js
+4
-4
test/unit/editor/TestSetScaleCommand.js
test/unit/editor/TestSetScaleCommand.js
+4
-4
test/unit/editor/TestSetSceneCommand.js
test/unit/editor/TestSetSceneCommand.js
+3
-3
test/unit/editor/TestSetScriptValueCommand.js
test/unit/editor/TestSetScriptValueCommand.js
+6
-6
test/unit/editor/TestSetUuidCommand.js
test/unit/editor/TestSetUuidCommand.js
+4
-4
test/unit/editor/TestSetValueCommand.js
test/unit/editor/TestSetValueCommand.js
+5
-5
test/unit/unittests_editor.html
test/unit/unittests_editor.html
+40
-40
未找到文件。
editor/docs/Implementing additional commands for undo-redo.md
浏览文件 @
62ebe779
...
...
@@ -28,7 +28,7 @@ Every command needs a constructor. In the constructor
CmdXXX
=
function
()
{
C
m
d
.
call
(
this
);
// Required: Call default constructor
C
omman
d
.
call
(
this
);
// Required: Call default constructor
this
.
type
=
'
CmdXXX
'
;
// Required: has to match the object-name!
this
.
name
=
'
Set/Do/Update XXX
'
;
// Required: description of the command, used in Sidebar.History
...
...
@@ -62,7 +62,7 @@ CmdXXX.prototype = {
toJSON
:
function
()
{
var
output
=
C
md
.
prototype
.
toJSON
.
call
(
this
);
// Required: Call 'toJSON'-method of prototype 'Cm
d'
var
output
=
C
ommand
.
prototype
.
toJSON
.
call
(
this
);
// Required: Call 'toJSON'-method of prototype 'Comman
d'
// TODO: serialize all the necessary information as part of 'output' (JSON-format)
// so that it can be restored in 'fromJSON'
...
...
@@ -73,7 +73,7 @@ CmdXXX.prototype = {
fromJSON
:
function
(
json
)
{
C
md
.
prototype
.
fromJSON
.
call
(
this
,
json
);
// Required: Call 'fromJSON'-method of prototype 'Cm
d'
C
ommand
.
prototype
.
fromJSON
.
call
(
this
,
json
);
// Required: Call 'fromJSON'-method of prototype 'Comman
d'
// TODO: restore command from json
...
...
@@ -99,7 +99,7 @@ editor.execute( new CmdXXX() );
Some commands are also
**updatable**
. By default a command is not updatable. Making a command updatable means that you
have to implement a fifth function 'update' as part of the prototype. In it only the 'new' state gets updated while the old one stays the same.
Here as an example is the update-function of
**
CmdSetColor
**
:
Here as an example is the update-function of
**
SetColorCommand
**
:
```
javascript
update
:
function
(
cmd
)
{
...
...
@@ -112,15 +112,15 @@ update: function ( cmd ) {
#### List of updatable commands
-
CmdSetColor
-
CmdSetGeometry
-
CmdSetMaterialColor
-
CmdSetMaterialValue
-
CmdSetPosition
-
CmdSetRotation
-
CmdSetScale
-
CmdSetValue
-
CmdSetScriptValue
-
SetColorCommand
-
SetGeometryCommand
-
SetMaterialColorCommand
-
SetMaterialValueCommand
-
SetPositionCommand
-
SetRotationCommand
-
SetScaleCommand
-
SetValueCommand
-
SetScriptValueCommand
The idea behind 'updatable commands' is that two commands of the same type which occur
within a short period of time should be merged into one.
...
...
editor/docs/Writing unit tests for undo-redo commands.md
浏览文件 @
62ebe779
...
...
@@ -26,8 +26,8 @@ Within the file, go to the `<!-- command object classes -->` and include the new
```
javascript
// <!-- command object classes -->
//...
<
script
src
=
"
../../editor/js/
CmdSetUui
d.js
"
><
/script
>
<
script
src
=
"
../../editor/js/
CmdSetValue
.js
"
><
/script
>
<
script
src
=
"
../../editor/js/
SetUuidComman
d.js
"
><
/script
>
<
script
src
=
"
../../editor/js/
SetValueCommand
.js
"
><
/script
>
<
script
src
=
"
../../editor/js/CmdXXX.js
"
><
/script> /
/
add
this
line
//...
```
...
...
@@ -39,7 +39,7 @@ Next, in the same file, go to `<!-- Undo-Redo tests -->` and include the test fi
```
javascript
// <!-- Undo-Redo tests -->
//...
<
script
src
=
"
editor/Test
CmdSetValue
.js
"
><
/script
>
<
script
src
=
"
editor/Test
SetValueCommand
.js
"
><
/script
>
<
script
src
=
"
editor/TestCmdXXX.js
"
><
/script> /
/
add
this
line
<
script
src
=
"
editor/TestNestedDoUndoRedo.js
"
><
/script
>
//...
...
...
@@ -68,7 +68,7 @@ test("Test CmdXXX (Undo and Redo)", function() {
// var perspectiveCamera = aPerspectiveCamera( 'Name your perspectiveCamera' );
// in most cases you'll need to add the object to work with
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
// your test begins here...
...
...
editor/index.html
浏览文件 @
62ebe779
...
...
@@ -124,27 +124,27 @@
<script
src=
"js/Toolbar.js"
></script>
<script
src=
"js/Viewport.js"
></script>
<script
src=
"js/Viewport.Info.js"
></script>
<script
src=
"js/C
m
d.js"
></script>
<script
src=
"js/
CmdAddObject
.js"
></script>
<script
src=
"js/
CmdRemoveObject
.js"
></script>
<script
src=
"js/
CmdMoveObject
.js"
></script>
<script
src=
"js/
CmdSetPosition
.js"
></script>
<script
src=
"js/
CmdSetRotation
.js"
></script>
<script
src=
"js/
CmdSetScale
.js"
></script>
<script
src=
"js/
CmdSetValue
.js"
></script>
<script
src=
"js/
CmdSetUui
d.js"
></script>
<script
src=
"js/
CmdSetColor
.js"
></script>
<script
src=
"js/
CmdSetGeometry
.js"
></script>
<script
src=
"js/
CmdSetGeometryValue
.js"
></script>
<script
src=
"js/
CmdMultiCmds
.js"
></script>
<script
src=
"js/
CmdAddScript
.js"
></script>
<script
src=
"js/
CmdRemoveScript
.js"
></script>
<script
src=
"js/
CmdSetScriptValue
.js"
></script>
<script
src=
"js/
CmdSetMaterial
.js"
></script>
<script
src=
"js/
CmdSetMaterialValue
.js"
></script>
<script
src=
"js/
CmdSetMaterialColor
.js"
></script>
<script
src=
"js/
CmdSetMaterialMap
.js"
></script>
<script
src=
"js/
CmdSetScene
.js"
></script>
<script
src=
"js/C
omman
d.js"
></script>
<script
src=
"js/
commands/AddObjectCommand
.js"
></script>
<script
src=
"js/
commands/RemoveObjectCommand
.js"
></script>
<script
src=
"js/
commands/MoveObjectCommand
.js"
></script>
<script
src=
"js/
commands/SetPositionCommand
.js"
></script>
<script
src=
"js/
commands/SetRotationCommand
.js"
></script>
<script
src=
"js/
commands/SetScaleCommand
.js"
></script>
<script
src=
"js/
commands/SetValueCommand
.js"
></script>
<script
src=
"js/
commands/SetUuidComman
d.js"
></script>
<script
src=
"js/
commands/SetColorCommand
.js"
></script>
<script
src=
"js/
commands/SetGeometryCommand
.js"
></script>
<script
src=
"js/
commands/SetGeometryValueCommand
.js"
></script>
<script
src=
"js/
commands/MultiCmdsCommand
.js"
></script>
<script
src=
"js/
commands/AddScriptCommand
.js"
></script>
<script
src=
"js/
commands/RemoveScriptCommand
.js"
></script>
<script
src=
"js/
commands/SetScriptValueCommand
.js"
></script>
<script
src=
"js/
commands/SetMaterialCommand
.js"
></script>
<script
src=
"js/
commands/SetMaterialValueCommand
.js"
></script>
<script
src=
"js/
commands/SetMaterialColorCommand
.js"
></script>
<script
src=
"js/
commands/SetMaterialMapCommand
.js"
></script>
<script
src=
"js/
commands/SetSceneCommand
.js"
></script>
<script>
...
...
@@ -286,7 +286,7 @@
if
(
confirm
(
'
Delete
'
+
object
.
name
+
'
?
'
)
===
false
)
return
;
var
parent
=
object
.
parent
;
if
(
parent
!==
null
)
editor
.
execute
(
new
CmdRemoveObject
(
object
)
);
if
(
parent
!==
null
)
editor
.
execute
(
new
RemoveObjectCommand
(
object
)
);
break
;
...
...
editor/js/C
m
d.js
→
editor/js/C
omman
d.js
浏览文件 @
62ebe779
...
...
@@ -9,7 +9,7 @@
* @constructor
*/
C
m
d
=
function
(
editorRef
)
{
C
omman
d
=
function
(
editorRef
)
{
this
.
id
=
-
1
;
this
.
inMemory
=
false
;
...
...
@@ -19,15 +19,15 @@ Cmd = function ( editorRef ) {
if
(
editorRef
!==
undefined
)
{
C
m
d
.
editor
=
editorRef
;
C
omman
d
.
editor
=
editorRef
;
}
this
.
editor
=
C
m
d
.
editor
;
this
.
editor
=
C
omman
d
.
editor
;
};
C
m
d
.
prototype
.
toJSON
=
function
()
{
C
omman
d
.
prototype
.
toJSON
=
function
()
{
var
output
=
{};
output
.
type
=
this
.
type
;
...
...
@@ -37,7 +37,7 @@ Cmd.prototype.toJSON = function () {
};
C
m
d
.
prototype
.
fromJSON
=
function
(
json
)
{
C
omman
d
.
prototype
.
fromJSON
=
function
(
json
)
{
this
.
inMemory
=
true
;
this
.
type
=
json
.
type
;
...
...
editor/js/History.js
浏览文件 @
62ebe779
...
...
@@ -14,9 +14,9 @@ History = function ( editor ) {
this
.
historyDisabled
=
false
;
this
.
config
=
editor
.
config
;
//Set editor-reference in C
m
d
//Set editor-reference in C
omman
d
C
m
d
(
editor
);
C
omman
d
(
editor
);
// signals
...
...
@@ -51,9 +51,9 @@ History.prototype = {
lastCmd
.
script
===
cmd
.
script
&&
lastCmd
.
attributeName
===
cmd
.
attributeName
;
if
(
isUpdatableCmd
&&
cmd
.
type
===
"
CmdSetScriptValue
"
)
{
if
(
isUpdatableCmd
&&
cmd
.
type
===
"
SetScriptValueCommand
"
)
{
// When the cmd.type is "
CmdSetScriptValue
" the timeDifference is ignored
// When the cmd.type is "
SetScriptValueCommand
" the timeDifference is ignored
lastCmd
.
update
(
cmd
);
cmd
=
lastCmd
;
...
...
editor/js/Loader.js
浏览文件 @
62ebe779
...
...
@@ -24,7 +24,7 @@ var Loader = function ( editor ) {
var
loader
=
new
THREE
.
AMFLoader
();
var
amfobject
=
loader
.
parse
(
event
.
target
.
result
);
editor
.
execute
(
new
CmdAddObject
(
amfobject
)
);
editor
.
execute
(
new
AddObjectCommand
(
amfobject
)
);
},
false
);
reader
.
readAsArrayBuffer
(
file
);
...
...
@@ -39,7 +39,7 @@ var Loader = function ( editor ) {
var
loader
=
new
THREE
.
AWDLoader
();
var
scene
=
loader
.
parse
(
event
.
target
.
result
);
editor
.
execute
(
new
CmdSetScene
(
scene
)
);
editor
.
execute
(
new
SetSceneCommand
(
scene
)
);
},
false
);
reader
.
readAsArrayBuffer
(
file
);
...
...
@@ -57,7 +57,7 @@ var Loader = function ( editor ) {
var
loader
=
new
THREE
.
BabylonLoader
();
var
scene
=
loader
.
parse
(
json
);
editor
.
execute
(
new
CmdSetScene
(
scene
)
);
editor
.
execute
(
new
SetSceneCommand
(
scene
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -80,7 +80,7 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -108,7 +108,7 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
...
...
@@ -129,7 +129,7 @@ var Loader = function ( editor ) {
collada
.
scene
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
collada
.
scene
)
);
editor
.
execute
(
new
AddObjectCommand
(
collada
.
scene
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -204,7 +204,7 @@ var Loader = function ( editor ) {
collada
.
scene
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
collada
.
scene
)
);
editor
.
execute
(
new
AddObjectCommand
(
collada
.
scene
)
);
},
false
);
reader
.
readAsArrayBuffer
(
file
);
...
...
@@ -228,7 +228,7 @@ var Loader = function ( editor ) {
mesh
.
mixer
=
new
THREE
.
AnimationMixer
(
mesh
)
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
},
false
);
reader
.
readAsArrayBuffer
(
file
);
...
...
@@ -245,7 +245,7 @@ var Loader = function ( editor ) {
var
object
=
new
THREE
.
OBJLoader
().
parse
(
contents
);
object
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
object
)
);
editor
.
execute
(
new
AddObjectCommand
(
object
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -263,7 +263,7 @@ var Loader = function ( editor ) {
var
loader
=
new
THREE
.
PlayCanvasLoader
();
var
object
=
loader
.
parse
(
json
);
editor
.
execute
(
new
CmdAddObject
(
object
)
);
editor
.
execute
(
new
AddObjectCommand
(
object
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -286,7 +286,7 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -309,7 +309,7 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
},
false
);
...
...
@@ -338,7 +338,7 @@ var Loader = function ( editor ) {
var mesh = new THREE.Mesh( geometry, material );
editor.execute( new
CmdAddObject
( mesh ) );
editor.execute( new
AddObjectCommand
( mesh ) );
}, false );
reader.readAsBinaryString( file );
...
...
@@ -362,7 +362,7 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -378,7 +378,7 @@ var Loader = function ( editor ) {
var
result
=
new
THREE
.
VRMLLoader
().
parse
(
contents
);
editor
.
execute
(
new
CmdSetScene
(
result
)
);
editor
.
execute
(
new
SetSceneCommand
(
result
)
);
},
false
);
reader
.
readAsText
(
file
);
...
...
@@ -422,7 +422,7 @@ var Loader = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
result
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
else
if
(
data
.
metadata
.
type
.
toLowerCase
()
===
'
geometry
'
)
{
...
...
@@ -469,7 +469,7 @@ var Loader = function ( editor ) {
mesh
.
name
=
filename
;
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
else
if
(
data
.
metadata
.
type
.
toLowerCase
()
===
'
object
'
)
{
...
...
@@ -480,11 +480,11 @@ var Loader = function ( editor ) {
if
(
result
instanceof
THREE
.
Scene
)
{
editor
.
execute
(
new
CmdSetScene
(
result
)
);
editor
.
execute
(
new
SetSceneCommand
(
result
)
);
}
else
{
editor
.
execute
(
new
CmdAddObject
(
result
)
);
editor
.
execute
(
new
AddObjectCommand
(
result
)
);
}
...
...
@@ -495,7 +495,7 @@ var Loader = function ( editor ) {
var
loader
=
new
THREE
.
SceneLoader
();
loader
.
parse
(
data
,
function
(
result
)
{
editor
.
execute
(
new
CmdSetScene
(
result
.
scene
)
);
editor
.
execute
(
new
SetSceneCommand
(
result
.
scene
)
);
},
''
);
...
...
editor/js/Menubar.Add.js
浏览文件 @
62ebe779
...
...
@@ -40,7 +40,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Group
();
mesh
.
name
=
'
Group
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -67,7 +67,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
name
=
'
Plane
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -91,7 +91,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
Box
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -110,7 +110,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
Circle
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -133,7 +133,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
Cylinder
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -157,7 +157,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
Sphere
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -176,7 +176,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
Icosahedron
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -198,7 +198,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
Torus
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -222,7 +222,7 @@ Menubar.Add = function ( editor ) {
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
new
THREE
.
MeshPhongMaterial
()
);
mesh
.
name
=
'
TorusKnot
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
}
);
options
.
add
(
option
);
...
...
@@ -267,7 +267,7 @@ Menubar.Add = function ( editor ) {
var
sprite
=
new
THREE
.
Sprite
(
new
THREE
.
SpriteMaterial
()
);
sprite
.
name
=
'
Sprite
'
+
(
++
meshCount
);
editor
.
execute
(
new
CmdAddObject
(
sprite
)
);
editor
.
execute
(
new
AddObjectCommand
(
sprite
)
);
}
);
options
.
add
(
option
);
...
...
@@ -290,7 +290,7 @@ Menubar.Add = function ( editor ) {
var
light
=
new
THREE
.
PointLight
(
color
,
intensity
,
distance
);
light
.
name
=
'
PointLight
'
+
(
++
lightCount
);
editor
.
execute
(
new
CmdAddObject
(
light
)
);
editor
.
execute
(
new
AddObjectCommand
(
light
)
);
}
);
options
.
add
(
option
);
...
...
@@ -314,7 +314,7 @@ Menubar.Add = function ( editor ) {
light
.
position
.
set
(
0.5
,
1
,
0.75
).
multiplyScalar
(
200
);
editor
.
execute
(
new
CmdAddObject
(
light
)
);
editor
.
execute
(
new
AddObjectCommand
(
light
)
);
}
);
options
.
add
(
option
);
...
...
@@ -335,7 +335,7 @@ Menubar.Add = function ( editor ) {
light
.
position
.
set
(
0.5
,
1
,
0.75
).
multiplyScalar
(
200
);
editor
.
execute
(
new
CmdAddObject
(
light
)
);
editor
.
execute
(
new
AddObjectCommand
(
light
)
);
}
);
options
.
add
(
option
);
...
...
@@ -356,7 +356,7 @@ Menubar.Add = function ( editor ) {
light
.
position
.
set
(
0.5
,
1
,
0.75
).
multiplyScalar
(
200
);
editor
.
execute
(
new
CmdAddObject
(
light
)
);
editor
.
execute
(
new
AddObjectCommand
(
light
)
);
}
);
options
.
add
(
option
);
...
...
@@ -373,7 +373,7 @@ Menubar.Add = function ( editor ) {
var
light
=
new
THREE
.
AmbientLight
(
color
);
light
.
name
=
'
AmbientLight
'
+
(
++
lightCount
);
editor
.
execute
(
new
CmdAddObject
(
light
)
);
editor
.
execute
(
new
AddObjectCommand
(
light
)
);
}
);
options
.
add
(
option
);
...
...
@@ -392,7 +392,7 @@ Menubar.Add = function ( editor ) {
var
camera
=
new
THREE
.
PerspectiveCamera
(
50
,
1
,
1
,
10000
);
camera
.
name
=
'
PerspectiveCamera
'
+
(
++
cameraCount
);
editor
.
execute
(
new
CmdAddObject
(
camera
)
);
editor
.
execute
(
new
AddObjectCommand
(
camera
)
);
}
);
options
.
add
(
option
);
...
...
editor/js/Menubar.Edit.js
浏览文件 @
62ebe779
...
...
@@ -95,7 +95,7 @@ Menubar.Edit = function ( editor ) {
object
=
object
.
clone
();
editor
.
execute
(
new
CmdAddObject
(
object
)
);
editor
.
execute
(
new
AddObjectCommand
(
object
)
);
}
);
options
.
add
(
option
);
...
...
@@ -114,7 +114,7 @@ Menubar.Edit = function ( editor ) {
var
parent
=
object
.
parent
;
if
(
parent
===
undefined
)
return
;
// avoid deleting the camera or scene
editor
.
execute
(
new
CmdRemoveObject
(
object
)
);
editor
.
execute
(
new
RemoveObjectCommand
(
object
)
);
}
);
options
.
add
(
option
);
...
...
@@ -158,8 +158,8 @@ Menubar.Edit = function ( editor ) {
var
shader
=
glslprep
.
minifyGlsl
(
[
material
.
vertexShader
,
material
.
fragmentShader
]
);
cmds
.
push
(
new
CmdSetMaterialValue
(
object
,
'
vertexShader
'
,
shader
[
0
]
)
);
cmds
.
push
(
new
CmdSetMaterialValue
(
object
,
'
fragmentShader
'
,
shader
[
1
]
)
);
cmds
.
push
(
new
SetMaterialValueCommand
(
object
,
'
vertexShader
'
,
shader
[
0
]
)
);
cmds
.
push
(
new
SetMaterialValueCommand
(
object
,
'
fragmentShader
'
,
shader
[
1
]
)
);
++
nMaterialsChanged
;
...
...
@@ -189,7 +189,7 @@ Menubar.Edit = function ( editor ) {
if
(
nMaterialsChanged
>
0
)
{
editor
.
execute
(
new
CmdMultiCmds
(
cmds
),
'
Minify Shaders
'
);
editor
.
execute
(
new
MultiCmdsCommand
(
cmds
),
'
Minify Shaders
'
);
}
...
...
editor/js/Script.js
浏览文件 @
62ebe779
...
...
@@ -82,7 +82,7 @@ var Script = function ( editor ) {
if
(
value
!==
currentScript
.
source
)
{
editor
.
execute
(
new
CmdSetScriptValue
(
currentObject
,
currentScript
,
'
source
'
,
value
,
codemirror
.
getCursor
()
)
);
editor
.
execute
(
new
SetScriptValueCommand
(
currentObject
,
currentScript
,
'
source
'
,
value
,
codemirror
.
getCursor
()
)
);
}
return
;
...
...
@@ -94,21 +94,21 @@ var Script = function ( editor ) {
if
(
JSON
.
stringify
(
currentObject
.
material
.
defines
)
!==
JSON
.
stringify
(
json
.
defines
)
)
{
var
cmd
=
new
CmdSetMaterialValue
(
currentObject
,
'
defines
'
,
json
.
defines
);
var
cmd
=
new
SetMaterialValueCommand
(
currentObject
,
'
defines
'
,
json
.
defines
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
}
if
(
JSON
.
stringify
(
currentObject
.
material
.
uniforms
)
!==
JSON
.
stringify
(
json
.
uniforms
)
)
{
var
cmd
=
new
CmdSetMaterialValue
(
currentObject
,
'
uniforms
'
,
json
.
uniforms
);
var
cmd
=
new
SetMaterialValueCommand
(
currentObject
,
'
uniforms
'
,
json
.
uniforms
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
}
if
(
JSON
.
stringify
(
currentObject
.
material
.
attributes
)
!==
JSON
.
stringify
(
json
.
attributes
)
)
{
var
cmd
=
new
CmdSetMaterialValue
(
currentObject
,
'
attributes
'
,
json
.
attributes
);
var
cmd
=
new
SetMaterialValueCommand
(
currentObject
,
'
attributes
'
,
json
.
attributes
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
editor/js/Sidebar.Geometry.BoxGeometry.js
浏览文件 @
62ebe779
...
...
@@ -74,7 +74,7 @@ Sidebar.Geometry.BoxGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
BoxGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
BoxGeometry
(
width
.
getValue
(),
height
.
getValue
(),
depth
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.CircleGeometry.js
浏览文件 @
62ebe779
...
...
@@ -54,7 +54,7 @@ Sidebar.Geometry.CircleGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
CircleGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
CircleGeometry
(
radius
.
getValue
(),
segments
.
getValue
(),
thetaStart
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.CylinderGeometry.js
浏览文件 @
62ebe779
...
...
@@ -74,7 +74,7 @@ Sidebar.Geometry.CylinderGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
CylinderGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
CylinderGeometry
(
radiusTop
.
getValue
(),
radiusBottom
.
getValue
(),
height
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.IcosahedronGeometry.js
浏览文件 @
62ebe779
...
...
@@ -35,7 +35,7 @@ Sidebar.Geometry.IcosahedronGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
IcosahedronGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
IcosahedronGeometry
(
radius
.
getValue
(),
detail
.
getValue
()
)
)
);
...
...
editor/js/Sidebar.Geometry.PlaneGeometry.js
浏览文件 @
62ebe779
...
...
@@ -55,7 +55,7 @@ Sidebar.Geometry.PlaneGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
PlaneGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
PlaneGeometry
(
width
.
getValue
(),
height
.
getValue
(),
widthSegments
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.SphereGeometry.js
浏览文件 @
62ebe779
...
...
@@ -85,7 +85,7 @@ Sidebar.Geometry.SphereGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
SphereGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
SphereGeometry
(
radius
.
getValue
(),
widthSegments
.
getValue
(),
heightSegments
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.TorusGeometry.js
浏览文件 @
62ebe779
...
...
@@ -65,7 +65,7 @@ Sidebar.Geometry.TorusGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
TorusGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
TorusGeometry
(
radius
.
getValue
(),
tube
.
getValue
(),
radialSegments
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.TorusKnotGeometry.js
浏览文件 @
62ebe779
...
...
@@ -85,7 +85,7 @@ Sidebar.Geometry.TorusKnotGeometry = function ( editor, object ) {
function
update
()
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
TorusKnotGeometry
(
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
TorusKnotGeometry
(
radius
.
getValue
(),
tube
.
getValue
(),
radialSegments
.
getValue
(),
...
...
editor/js/Sidebar.Geometry.js
浏览文件 @
62ebe779
...
...
@@ -51,7 +51,7 @@ Sidebar.Geometry = function ( editor ) {
var
newPosition
=
object
.
position
.
clone
();
newPosition
.
sub
(
offset
);
editor
.
execute
(
new
CmdSetPosition
(
object
,
newPosition
)
);
editor
.
execute
(
new
SetPositionCommand
(
object
,
newPosition
)
);
editor
.
signals
.
geometryChanged
.
dispatch
(
object
);
...
...
@@ -61,7 +61,7 @@ Sidebar.Geometry = function ( editor ) {
if
(
geometry
instanceof
THREE
.
Geometry
)
{
editor
.
execute
(
new
CmdSetGeometry
(
object
,
new
THREE
.
BufferGeometry
().
fromGeometry
(
geometry
)
)
);
editor
.
execute
(
new
SetGeometryCommand
(
object
,
new
THREE
.
BufferGeometry
().
fromGeometry
(
geometry
)
)
);
}
...
...
@@ -73,12 +73,12 @@ Sidebar.Geometry = function ( editor ) {
newGeometry
.
uuid
=
geometry
.
uuid
;
newGeometry
.
applyMatrix
(
object
.
matrix
);
var
cmds
=
[
new
CmdSetGeometry
(
object
,
newGeometry
),
new
CmdSetPosition
(
object
,
new
THREE
.
Vector3
(
0
,
0
,
0
)
),
new
CmdSetRotation
(
object
,
new
THREE
.
Euler
(
0
,
0
,
0
)
),
new
CmdSetScale
(
object
,
new
THREE
.
Vector3
(
1
,
1
,
1
)
)
];
var
cmds
=
[
new
SetGeometryCommand
(
object
,
newGeometry
),
new
SetPositionCommand
(
object
,
new
THREE
.
Vector3
(
0
,
0
,
0
)
),
new
SetRotationCommand
(
object
,
new
THREE
.
Euler
(
0
,
0
,
0
)
),
new
SetScaleCommand
(
object
,
new
THREE
.
Vector3
(
1
,
1
,
1
)
)
];
editor
.
execute
(
new
CmdMultiCmds
(
cmds
),
'
Flatten Geometry
'
);
editor
.
execute
(
new
MultiCmdsCommand
(
cmds
),
'
Flatten Geometry
'
);
break
;
...
...
@@ -99,7 +99,7 @@ Sidebar.Geometry = function ( editor ) {
geometryUUID
.
setValue
(
THREE
.
Math
.
generateUUID
()
);
editor
.
execute
(
new
CmdSetGeometryValue
(
editor
.
selected
,
'
uuid
'
,
geometryUUID
.
getValue
()
)
);
editor
.
execute
(
new
SetGeometryValueCommand
(
editor
.
selected
,
'
uuid
'
,
geometryUUID
.
getValue
()
)
);
}
);
...
...
@@ -114,7 +114,7 @@ Sidebar.Geometry = function ( editor ) {
var
geometryNameRow
=
new
UI
.
Panel
();
var
geometryName
=
new
UI
.
Input
().
setWidth
(
'
150px
'
).
setFontSize
(
'
12px
'
).
onChange
(
function
()
{
editor
.
execute
(
new
CmdSetGeometryValue
(
editor
.
selected
,
'
name
'
,
geometryName
.
getValue
()
)
);
editor
.
execute
(
new
SetGeometryValueCommand
(
editor
.
selected
,
'
name
'
,
geometryName
.
getValue
()
)
);
}
);
...
...
editor/js/Sidebar.Material.js
浏览文件 @
62ebe779
...
...
@@ -42,7 +42,7 @@ Sidebar.Material = function ( editor ) {
var
materialNameRow
=
new
UI
.
Panel
();
var
materialName
=
new
UI
.
Input
().
setWidth
(
'
150px
'
).
setFontSize
(
'
12px
'
).
onChange
(
function
()
{
editor
.
execute
(
new
CmdSetMaterialValue
(
editor
.
selected
,
'
name
'
,
materialName
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
.
selected
,
'
name
'
,
materialName
.
getValue
()
)
);
}
);
...
...
@@ -402,7 +402,7 @@ Sidebar.Material = function ( editor ) {
if
(
material
.
uuid
!==
undefined
&&
material
.
uuid
!==
materialUUID
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
uuid
'
,
materialUUID
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
uuid
'
,
materialUUID
.
getValue
()
)
);
}
...
...
@@ -410,7 +410,7 @@ Sidebar.Material = function ( editor ) {
material
=
new
THREE
[
materialClass
.
getValue
()
]();
editor
.
execute
(
new
CmdSetMaterial
(
currentObject
,
material
),
'
New Material:
'
+
materialClass
.
getValue
()
);
editor
.
execute
(
new
SetMaterialCommand
(
currentObject
,
material
),
'
New Material:
'
+
materialClass
.
getValue
()
);
// TODO Copy other references in the scene graph
// keeping name and UUID then.
// Also there should be means to create a unique
...
...
@@ -421,25 +421,25 @@ Sidebar.Material = function ( editor ) {
if
(
material
.
color
!==
undefined
&&
material
.
color
.
getHex
()
!==
materialColor
.
getHexValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialColor
(
currentObject
,
'
color
'
,
materialColor
.
getHexValue
()
)
);
editor
.
execute
(
new
SetMaterialColorCommand
(
currentObject
,
'
color
'
,
materialColor
.
getHexValue
()
)
);
}
if
(
material
.
emissive
!==
undefined
&&
material
.
emissive
.
getHex
()
!==
materialEmissive
.
getHexValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialColor
(
currentObject
,
'
emissive
'
,
materialEmissive
.
getHexValue
()
)
);
editor
.
execute
(
new
SetMaterialColorCommand
(
currentObject
,
'
emissive
'
,
materialEmissive
.
getHexValue
()
)
);
}
if
(
material
.
specular
!==
undefined
&&
material
.
specular
.
getHex
()
!==
materialSpecular
.
getHexValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialColor
(
currentObject
,
'
specular
'
,
materialSpecular
.
getHexValue
()
)
);
editor
.
execute
(
new
SetMaterialColorCommand
(
currentObject
,
'
specular
'
,
materialSpecular
.
getHexValue
()
)
);
}
if
(
material
.
shininess
!==
undefined
&&
Math
.
abs
(
material
.
shininess
-
materialShininess
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
shininess
'
,
materialShininess
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
shininess
'
,
materialShininess
.
getValue
()
)
);
}
...
...
@@ -449,7 +449,7 @@ Sidebar.Material = function ( editor ) {
if
(
material
.
vertexColors
!==
vertexColors
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
vertexColors
'
,
vertexColors
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
vertexColors
'
,
vertexColors
)
);
}
...
...
@@ -457,7 +457,7 @@ Sidebar.Material = function ( editor ) {
if
(
material
.
skinning
!==
undefined
&&
material
.
skinning
!==
materialSkinning
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
skinning
'
,
materialSkinning
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
skinning
'
,
materialSkinning
.
getValue
()
)
);
}
...
...
@@ -470,7 +470,7 @@ Sidebar.Material = function ( editor ) {
var
map
=
mapEnabled
?
materialMap
.
getValue
()
:
null
;
if
(
material
.
map
!==
map
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
map
'
,
map
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
map
'
,
map
)
);
}
...
...
@@ -491,7 +491,7 @@ Sidebar.Material = function ( editor ) {
var
alphaMap
=
mapEnabled
?
materialAlphaMap
.
getValue
()
:
null
;
if
(
material
.
alphaMap
!==
alphaMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
alphaMap
'
,
alphaMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
alphaMap
'
,
alphaMap
)
);
}
...
...
@@ -512,13 +512,13 @@ Sidebar.Material = function ( editor ) {
var
bumpMap
=
bumpMapEnabled
?
materialBumpMap
.
getValue
()
:
null
;
if
(
material
.
bumpMap
!==
bumpMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
bumpMap
'
,
bumpMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
bumpMap
'
,
bumpMap
)
);
}
if
(
material
.
bumpScale
!==
materialBumpScale
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
bumpScale
'
,
materialBumpScale
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
bumpScale
'
,
materialBumpScale
.
getValue
()
)
);
}
...
...
@@ -539,7 +539,7 @@ Sidebar.Material = function ( editor ) {
var
normalMap
=
normalMapEnabled
?
materialNormalMap
.
getValue
()
:
null
;
if
(
material
.
normalMap
!==
normalMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
normalMap
'
,
normalMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
normalMap
'
,
normalMap
)
);
}
...
...
@@ -560,13 +560,13 @@ Sidebar.Material = function ( editor ) {
var
displacementMap
=
displacementMapEnabled
?
materialDisplacementMap
.
getValue
()
:
null
;
if
(
material
.
displacementMap
!==
displacementMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
displacementMap
'
,
displacementMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
displacementMap
'
,
displacementMap
)
);
}
if
(
material
.
displacementScale
!==
materialDisplacementScale
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
displacementScale
'
,
materialDisplacementScale
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
displacementScale
'
,
materialDisplacementScale
.
getValue
()
)
);
}
...
...
@@ -587,7 +587,7 @@ Sidebar.Material = function ( editor ) {
var
specularMap
=
specularMapEnabled
?
materialSpecularMap
.
getValue
()
:
null
;
if
(
material
.
specularMap
!==
specularMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
specularMap
'
,
specularMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
specularMap
'
,
specularMap
)
);
}
...
...
@@ -607,13 +607,13 @@ Sidebar.Material = function ( editor ) {
if
(
material
.
envMap
!==
envMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
envMap
'
,
envMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
envMap
'
,
envMap
)
);
}
if
(
material
.
reflectivity
!==
materialReflectivity
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
reflectivity
'
,
materialReflectivity
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
reflectivity
'
,
materialReflectivity
.
getValue
()
)
);
}
...
...
@@ -628,7 +628,7 @@ Sidebar.Material = function ( editor ) {
var
lightMap
=
lightMapEnabled
?
materialLightMap
.
getValue
()
:
null
;
if
(
material
.
lightMap
!==
lightMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
lightMap
'
,
lightMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
lightMap
'
,
lightMap
)
);
}
...
...
@@ -649,13 +649,13 @@ Sidebar.Material = function ( editor ) {
var
aoMap
=
aoMapEnabled
?
materialAOMap
.
getValue
()
:
null
;
if
(
material
.
aoMap
!==
aoMap
)
{
editor
.
execute
(
new
CmdSetMaterialMap
(
currentObject
,
'
aoMap
'
,
aoMap
)
);
editor
.
execute
(
new
SetMaterialMapCommand
(
currentObject
,
'
aoMap
'
,
aoMap
)
);
}
if
(
material
.
aoMapIntensity
!==
materialAOScale
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
aoMapIntensity
'
,
materialAOScale
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
aoMapIntensity
'
,
materialAOScale
.
getValue
()
)
);
}
...
...
@@ -672,7 +672,7 @@ Sidebar.Material = function ( editor ) {
var
side
=
parseInt
(
materialSide
.
getValue
()
);
if
(
material
.
side
!==
side
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
side
'
,
side
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
side
'
,
side
)
);
}
...
...
@@ -684,7 +684,7 @@ Sidebar.Material = function ( editor ) {
var
shading
=
parseInt
(
materialShading
.
getValue
()
);
if
(
material
.
shading
!==
shading
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
shading
'
,
shading
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
shading
'
,
shading
)
);
}
...
...
@@ -695,7 +695,7 @@ Sidebar.Material = function ( editor ) {
var
blending
=
parseInt
(
materialBlending
.
getValue
()
);
if
(
material
.
blending
!==
blending
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
blending
'
,
blending
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
blending
'
,
blending
)
);
}
...
...
@@ -703,31 +703,31 @@ Sidebar.Material = function ( editor ) {
if
(
material
.
opacity
!==
undefined
&&
Math
.
abs
(
material
.
opacity
-
materialOpacity
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
opacity
'
,
materialOpacity
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
opacity
'
,
materialOpacity
.
getValue
()
)
);
}
if
(
material
.
transparent
!==
undefined
&&
material
.
transparent
!==
materialTransparent
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
transparent
'
,
materialTransparent
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
transparent
'
,
materialTransparent
.
getValue
()
)
);
}
if
(
material
.
alphaTest
!==
undefined
&&
Math
.
abs
(
material
.
alphaTest
-
materialAlphaTest
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
alphaTest
'
,
materialAlphaTest
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
alphaTest
'
,
materialAlphaTest
.
getValue
()
)
);
}
if
(
material
.
wireframe
!==
undefined
&&
material
.
wireframe
!==
materialWireframe
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
wireframe
'
,
materialWireframe
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
wireframe
'
,
materialWireframe
.
getValue
()
)
);
}
if
(
material
.
wireframeLinewidth
!==
undefined
&&
Math
.
abs
(
material
.
wireframeLinewidth
-
materialWireframeLinewidth
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetMaterialValue
(
currentObject
,
'
wireframeLinewidth
'
,
materialWireframeLinewidth
.
getValue
()
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
currentObject
,
'
wireframeLinewidth
'
,
materialWireframeLinewidth
.
getValue
()
)
);
}
...
...
editor/js/Sidebar.Object3D.js
浏览文件 @
62ebe779
...
...
@@ -41,15 +41,15 @@ Sidebar.Object3D = function ( editor ) {
switch
(
this
.
getValue
()
)
{
case
'
Reset Position
'
:
editor
.
execute
(
new
CmdSetPosition
(
object
,
new
THREE
.
Vector3
(
0
,
0
,
0
)
)
);
editor
.
execute
(
new
SetPositionCommand
(
object
,
new
THREE
.
Vector3
(
0
,
0
,
0
)
)
);
break
;
case
'
Reset Rotation
'
:
editor
.
execute
(
new
CmdSetRotation
(
object
,
new
THREE
.
Euler
(
0
,
0
,
0
)
)
);
editor
.
execute
(
new
SetRotationCommand
(
object
,
new
THREE
.
Euler
(
0
,
0
,
0
)
)
);
break
;
case
'
Reset Scale
'
:
editor
.
execute
(
new
CmdSetScale
(
object
,
new
THREE
.
Vector3
(
1
,
1
,
1
)
)
);
editor
.
execute
(
new
SetScaleCommand
(
object
,
new
THREE
.
Vector3
(
1
,
1
,
1
)
)
);
break
;
}
...
...
@@ -69,7 +69,7 @@ Sidebar.Object3D = function ( editor ) {
objectUUID
.
setValue
(
THREE
.
Math
.
generateUUID
()
);
editor
.
execute
(
new
CmdSetUui
d
(
editor
.
selected
,
objectUUID
.
getValue
()
)
);
editor
.
execute
(
new
SetUuidComman
d
(
editor
.
selected
,
objectUUID
.
getValue
()
)
);
}
);
...
...
@@ -84,7 +84,7 @@ Sidebar.Object3D = function ( editor ) {
var
objectNameRow
=
new
UI
.
Panel
();
var
objectName
=
new
UI
.
Input
().
setWidth
(
'
150px
'
).
setFontSize
(
'
12px
'
).
onChange
(
function
()
{
editor
.
execute
(
new
CmdSetValue
(
editor
.
selected
,
'
name
'
,
objectName
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
editor
.
selected
,
'
name
'
,
objectName
.
getValue
()
)
);
}
);
...
...
@@ -373,7 +373,7 @@ Sidebar.Object3D = function ( editor ) {
if ( object.parent.id !== newParentId && object.id !== newParentId ) {
editor.execute( new
CmdMoveObject
( object, editor.scene.getObjectById( newParentId ) ) );
editor.execute( new
MoveObjectCommand
( object, editor.scene.getObjectById( newParentId ) ) );
}
...
...
@@ -383,100 +383,100 @@ Sidebar.Object3D = function ( editor ) {
var
newPosition
=
new
THREE
.
Vector3
(
objectPositionX
.
getValue
(),
objectPositionY
.
getValue
(),
objectPositionZ
.
getValue
()
);
if
(
object
.
position
.
distanceTo
(
newPosition
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetPosition
(
object
,
newPosition
)
);
editor
.
execute
(
new
SetPositionCommand
(
object
,
newPosition
)
);
}
var
newRotation
=
new
THREE
.
Euler
(
objectRotationX
.
getValue
(),
objectRotationY
.
getValue
(),
objectRotationZ
.
getValue
()
);
if
(
object
.
rotation
.
toVector3
().
distanceTo
(
newRotation
.
toVector3
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetRotation
(
object
,
newRotation
)
);
editor
.
execute
(
new
SetRotationCommand
(
object
,
newRotation
)
);
}
var
newScale
=
new
THREE
.
Vector3
(
objectScaleX
.
getValue
(),
objectScaleY
.
getValue
(),
objectScaleZ
.
getValue
()
);
if
(
object
.
scale
.
distanceTo
(
newScale
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetScale
(
object
,
newScale
)
);
editor
.
execute
(
new
SetScaleCommand
(
object
,
newScale
)
);
}
if
(
object
.
fov
!==
undefined
&&
Math
.
abs
(
object
.
fov
-
objectFov
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
fov
'
,
objectFov
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
fov
'
,
objectFov
.
getValue
()
)
);
object
.
updateProjectionMatrix
();
}
if
(
object
.
near
!==
undefined
&&
Math
.
abs
(
object
.
near
-
objectNear
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
near
'
,
objectNear
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
near
'
,
objectNear
.
getValue
()
)
);
}
if
(
object
.
far
!==
undefined
&&
Math
.
abs
(
object
.
far
-
objectFar
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
far
'
,
objectFar
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
far
'
,
objectFar
.
getValue
()
)
);
}
if
(
object
.
intensity
!==
undefined
&&
Math
.
abs
(
object
.
intensity
-
objectIntensity
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
intensity
'
,
objectIntensity
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
intensity
'
,
objectIntensity
.
getValue
()
)
);
}
if
(
object
.
color
!==
undefined
&&
object
.
color
.
getHex
()
!==
objectColor
.
getHexValue
()
)
{
editor
.
execute
(
new
CmdSetColor
(
object
,
'
color
'
,
objectColor
.
getHexValue
()
)
);
editor
.
execute
(
new
SetColorCommand
(
object
,
'
color
'
,
objectColor
.
getHexValue
()
)
);
}
if
(
object
.
groundColor
!==
undefined
&&
object
.
groundColor
.
getHex
()
!==
objectGroundColor
.
getHexValue
()
)
{
editor
.
execute
(
new
CmdSetColor
(
object
,
'
groundColor
'
,
objectGroundColor
.
getHexValue
()
)
);
editor
.
execute
(
new
SetColorCommand
(
object
,
'
groundColor
'
,
objectGroundColor
.
getHexValue
()
)
);
}
if
(
object
.
distance
!==
undefined
&&
Math
.
abs
(
object
.
distance
-
objectDistance
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
distance
'
,
objectDistance
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
distance
'
,
objectDistance
.
getValue
()
)
);
}
if
(
object
.
angle
!==
undefined
&&
Math
.
abs
(
object
.
angle
-
objectAngle
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
angle
'
,
objectAngle
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
angle
'
,
objectAngle
.
getValue
()
)
);
}
if
(
object
.
exponent
!==
undefined
&&
Math
.
abs
(
object
.
exponent
-
objectExponent
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
exponent
'
,
objectExponent
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
exponent
'
,
objectExponent
.
getValue
()
)
);
}
if
(
object
.
decay
!==
undefined
&&
Math
.
abs
(
object
.
decay
-
objectDecay
.
getValue
()
)
>=
0.01
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
decay
'
,
objectDecay
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
decay
'
,
objectDecay
.
getValue
()
)
);
}
if
(
object
.
visible
!==
objectVisible
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
visible
'
,
objectVisible
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
visible
'
,
objectVisible
.
getValue
()
)
);
}
if
(
object
.
castShadow
!==
objectCastShadow
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
castShadow
'
,
objectCastShadow
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
castShadow
'
,
objectCastShadow
.
getValue
()
)
);
}
if
(
object
.
receiveShadow
!==
objectReceiveShadow
.
getValue
()
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
receiveShadow
'
,
objectReceiveShadow
.
getValue
()
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
receiveShadow
'
,
objectReceiveShadow
.
getValue
()
)
);
object
.
material
.
needsUpdate
=
true
;
}
...
...
@@ -486,7 +486,7 @@ Sidebar.Object3D = function ( editor ) {
var
userData
=
JSON
.
parse
(
objectUserData
.
getValue
()
);
if
(
JSON
.
stringify
(
object
.
userData
)
!=
JSON
.
stringify
(
userData
)
)
{
editor
.
execute
(
new
CmdSetValue
(
object
,
'
userData
'
,
userData
)
);
editor
.
execute
(
new
SetValueCommand
(
object
,
'
userData
'
,
userData
)
);
}
...
...
editor/js/Sidebar.Script.js
浏览文件 @
62ebe779
...
...
@@ -27,7 +27,7 @@ Sidebar.Script = function ( editor ) {
newScript
.
onClick
(
function
()
{
var
script
=
{
name
:
''
,
source
:
'
function update( event ) {}
'
};
editor
.
execute
(
new
CmdAddScript
(
editor
.
selected
,
script
)
);
editor
.
execute
(
new
AddScriptCommand
(
editor
.
selected
,
script
)
);
}
);
container
.
add
(
newScript
);
...
...
@@ -63,7 +63,7 @@ Sidebar.Script = function ( editor ) {
var
name
=
new
UI
.
Input
(
script
.
name
).
setWidth
(
'
130px
'
).
setFontSize
(
'
12px
'
);
name
.
onChange
(
function
()
{
editor
.
execute
(
new
CmdSetScriptValue
(
editor
.
selected
,
script
,
'
name
'
,
this
.
getValue
()
)
);
editor
.
execute
(
new
SetScriptValueCommand
(
editor
.
selected
,
script
,
'
name
'
,
this
.
getValue
()
)
);
}
);
scriptsContainer
.
add
(
name
);
...
...
@@ -83,7 +83,7 @@ Sidebar.Script = function ( editor ) {
if
(
confirm
(
'
Are you sure?
'
)
)
{
editor
.
execute
(
new
CmdRemoveScript
(
editor
.
selected
,
script
)
);
editor
.
execute
(
new
RemoveScriptCommand
(
editor
.
selected
,
script
)
);
}
...
...
editor/js/Viewport.js
浏览文件 @
62ebe779
...
...
@@ -82,21 +82,21 @@ var Viewport = function ( editor ) {
case
'
translate
'
:
if
(
!
objectPositionOnDown
.
equals
(
object
.
position
))
{
editor
.
execute
(
new
CmdSetPosition
(
object
,
object
.
position
,
objectPositionOnDown
));
editor
.
execute
(
new
SetPositionCommand
(
object
,
object
.
position
,
objectPositionOnDown
));
}
break
;
case
'
rotate
'
:
if
(
!
objectRotationOnDown
.
equals
(
object
.
rotation
))
{
editor
.
execute
(
new
CmdSetRotation
(
object
,
object
.
rotation
,
objectRotationOnDown
));
editor
.
execute
(
new
SetRotationCommand
(
object
,
object
.
rotation
,
objectRotationOnDown
));
}
break
;
case
'
scale
'
:
if
(
!
objectScaleOnDown
.
equals
(
object
.
scale
))
{
editor
.
execute
(
new
CmdSetScale
(
object
,
object
.
scale
,
objectScaleOnDown
));
editor
.
execute
(
new
SetScaleCommand
(
object
,
object
.
scale
,
objectScaleOnDown
));
}
break
;
...
...
editor/js/
CmdAddObject
.js
→
editor/js/
commands/AddObjectCommand
.js
浏览文件 @
62ebe779
...
...
@@ -8,11 +8,11 @@
* @constructor
*/
CmdAddObject
=
function
(
object
)
{
AddObjectCommand
=
function
(
object
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdAddObject
'
;
this
.
type
=
'
AddObjectCommand
'
;
this
.
object
=
object
;
if
(
object
!==
undefined
)
{
...
...
@@ -23,7 +23,7 @@ CmdAddObject = function ( object ) {
};
CmdAddObject
.
prototype
=
{
AddObjectCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -41,7 +41,7 @@ CmdAddObject.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
object
=
this
.
object
.
toJSON
();
return
output
;
...
...
@@ -50,7 +50,7 @@ CmdAddObject.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
object
.
object
.
uuid
);
...
...
editor/js/
CmdAddScript
.js
→
editor/js/
commands/AddScriptCommand
.js
浏览文件 @
62ebe779
...
...
@@ -9,11 +9,11 @@
* @constructor
*/
CmdAddScript
=
function
(
object
,
script
)
{
AddScriptCommand
=
function
(
object
,
script
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdAddScript
'
;
this
.
type
=
'
AddScriptCommand
'
;
this
.
name
=
'
Add Script
'
;
this
.
object
=
object
;
...
...
@@ -21,7 +21,7 @@ CmdAddScript = function ( object, script ) {
};
CmdAddScript
.
prototype
=
{
AddScriptCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -55,7 +55,7 @@ CmdAddScript.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
script
=
this
.
script
;
...
...
@@ -66,7 +66,7 @@ CmdAddScript.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
script
=
json
.
script
;
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
...
...
editor/js/
CmdMoveObject
.js
→
editor/js/
commands/MoveObjectCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdMoveObject
=
function
(
object
,
newParent
,
newBefore
)
{
MoveObjectCommand
=
function
(
object
,
newParent
,
newBefore
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdMoveObject
'
;
this
.
type
=
'
MoveObjectCommand
'
;
this
.
name
=
'
Move Object
'
;
this
.
object
=
object
;
...
...
@@ -42,7 +42,7 @@ CmdMoveObject = function ( object, newParent, newBefore ) {
};
CmdMoveObject
.
prototype
=
{
MoveObjectCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -70,7 +70,7 @@ CmdMoveObject.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
newParentUuid
=
this
.
newParent
.
uuid
;
...
...
@@ -84,7 +84,7 @@ CmdMoveObject.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
oldParent
=
this
.
editor
.
objectByUuid
(
json
.
oldParentUuid
);
...
...
editor/js/
CmdMultiCmds
.js
→
editor/js/
commands/MultiCmdsCommand
.js
浏览文件 @
62ebe779
...
...
@@ -8,18 +8,18 @@
* @constructor
*/
CmdMultiCmds
=
function
(
cmdArray
)
{
MultiCmdsCommand
=
function
(
cmdArray
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdMultiCmds
'
;
this
.
type
=
'
MultiCmdsCommand
'
;
this
.
name
=
'
Multiple Changes
'
;
this
.
cmdArray
=
(
cmdArray
!==
undefined
)
?
cmdArray
:
[];
};
CmdMultiCmds
.
prototype
=
{
MultiCmdsCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -53,7 +53,7 @@ CmdMultiCmds.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
var
cmds
=
[];
for
(
var
i
=
0
;
i
<
this
.
cmdArray
.
length
;
i
++
)
{
...
...
@@ -69,7 +69,7 @@ CmdMultiCmds.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
var
cmds
=
json
.
cmds
;
for
(
var
i
=
0
;
i
<
cmds
.
length
;
i
++
)
{
...
...
editor/js/
CmdRemoveObject
.js
→
editor/js/
commands/RemoveObjectCommand
.js
浏览文件 @
62ebe779
...
...
@@ -8,11 +8,11 @@
* @constructor
*/
CmdRemoveObject
=
function
(
object
)
{
RemoveObjectCommand
=
function
(
object
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdRemoveObject
'
;
this
.
type
=
'
RemoveObjectCommand
'
;
this
.
name
=
'
Remove Object
'
;
this
.
object
=
object
;
...
...
@@ -25,7 +25,7 @@ CmdRemoveObject = function ( object ) {
};
CmdRemoveObject
.
prototype
=
{
RemoveObjectCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -68,7 +68,7 @@ CmdRemoveObject.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
object
=
this
.
object
.
toJSON
();
output
.
index
=
this
.
index
;
output
.
parentUuid
=
this
.
parent
.
uuid
;
...
...
@@ -79,7 +79,7 @@ CmdRemoveObject.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
parent
=
this
.
editor
.
objectByUuid
(
json
.
parentUuid
);
if
(
this
.
parent
===
undefined
)
{
...
...
editor/js/
CmdRemoveScript
.js
→
editor/js/
commands/RemoveScriptCommand
.js
浏览文件 @
62ebe779
...
...
@@ -9,11 +9,11 @@
* @constructor
*/
CmdRemoveScript
=
function
(
object
,
script
)
{
RemoveScriptCommand
=
function
(
object
,
script
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdRemoveScript
'
;
this
.
type
=
'
RemoveScriptCommand
'
;
this
.
name
=
'
Remove Script
'
;
this
.
object
=
object
;
...
...
@@ -26,7 +26,7 @@ CmdRemoveScript = function ( object, script ) {
};
CmdRemoveScript
.
prototype
=
{
RemoveScriptCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -58,7 +58,7 @@ CmdRemoveScript.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
script
=
this
.
script
;
...
...
@@ -70,7 +70,7 @@ CmdRemoveScript.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
script
=
json
.
script
;
this
.
index
=
json
.
index
;
...
...
editor/js/
CmdSetColor
.js
→
editor/js/
commands/SetColorCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetColor
=
function
(
object
,
attributeName
,
newValue
)
{
SetColorCommand
=
function
(
object
,
attributeName
,
newValue
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetColor
'
;
this
.
type
=
'
SetColorCommand
'
;
this
.
name
=
'
Set
'
+
attributeName
;
this
.
updatable
=
true
;
...
...
@@ -25,7 +25,7 @@ CmdSetColor = function ( object, attributeName, newValue ) {
};
CmdSetColor
.
prototype
=
{
SetColorCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -49,7 +49,7 @@ CmdSetColor.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
attributeName
=
this
.
attributeName
;
...
...
@@ -62,7 +62,7 @@ CmdSetColor.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
attributeName
=
json
.
attributeName
;
...
...
editor/js/
CmdSetGeometry
.js
→
editor/js/
commands/SetGeometryCommand
.js
浏览文件 @
62ebe779
...
...
@@ -9,11 +9,11 @@
* @constructor
*/
CmdSetGeometry
=
function
(
object
,
newGeometry
)
{
SetGeometryCommand
=
function
(
object
,
newGeometry
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetGeometry
'
;
this
.
type
=
'
SetGeometryCommand
'
;
this
.
name
=
'
Set Geometry
'
;
this
.
updatable
=
true
;
...
...
@@ -23,7 +23,7 @@ CmdSetGeometry = function ( object, newGeometry ) {
};
CmdSetGeometry
.
prototype
=
{
SetGeometryCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -55,7 +55,7 @@ CmdSetGeometry.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
oldGeometry
=
this
.
object
.
geometry
.
toJSON
();
...
...
@@ -67,7 +67,7 @@ CmdSetGeometry.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
...
...
editor/js/
CmdSetGeometryValue
.js
→
editor/js/
commands/SetGeometryValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetGeometryValue
=
function
(
object
,
attributeName
,
newValue
)
{
SetGeometryValueCommand
=
function
(
object
,
attributeName
,
newValue
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetGeometryValue
'
;
this
.
type
=
'
SetGeometryValueCommand
'
;
this
.
name
=
'
Set Geometry.
'
+
attributeName
;
this
.
object
=
object
;
...
...
@@ -24,7 +24,7 @@ CmdSetGeometryValue = function ( object, attributeName, newValue ) {
};
CmdSetGeometryValue
.
prototype
=
{
SetGeometryValueCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -46,7 +46,7 @@ CmdSetGeometryValue.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
attributeName
=
this
.
attributeName
;
...
...
@@ -59,7 +59,7 @@ CmdSetGeometryValue.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
attributeName
=
json
.
attributeName
;
...
...
editor/js/
CmdSetMaterialColor
.js
→
editor/js/
commands/SetMaterialColorCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetMaterialColor
=
function
(
object
,
attributeName
,
newValue
)
{
SetMaterialColorCommand
=
function
(
object
,
attributeName
,
newValue
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetMaterialColor
'
;
this
.
type
=
'
SetMaterialColorCommand
'
;
this
.
name
=
'
Set Material.
'
+
attributeName
;
this
.
updatable
=
true
;
...
...
@@ -25,7 +25,7 @@ CmdSetMaterialColor = function ( object, attributeName, newValue ) {
};
CmdSetMaterialColor
.
prototype
=
{
SetMaterialColorCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -49,7 +49,7 @@ CmdSetMaterialColor.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
attributeName
=
this
.
attributeName
;
...
...
@@ -62,7 +62,7 @@ CmdSetMaterialColor.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
attributeName
=
json
.
attributeName
;
...
...
editor/js/
CmdSetMaterial
.js
→
editor/js/
commands/SetMaterialCommand
.js
浏览文件 @
62ebe779
...
...
@@ -9,11 +9,11 @@
* @constructor
*/
CmdSetMaterial
=
function
(
object
,
newMaterial
)
{
SetMaterialCommand
=
function
(
object
,
newMaterial
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetMaterial
'
;
this
.
type
=
'
SetMaterialCommand
'
;
this
.
name
=
'
New Material
'
;
this
.
object
=
object
;
...
...
@@ -22,7 +22,7 @@ CmdSetMaterial = function ( object, newMaterial ) {
};
CmdSetMaterial
.
prototype
=
{
SetMaterialCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -40,7 +40,7 @@ CmdSetMaterial.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
oldMaterial
=
this
.
oldMaterial
.
toJSON
();
...
...
@@ -52,7 +52,7 @@ CmdSetMaterial.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
oldMaterial
=
parseMaterial
(
json
.
oldMaterial
);
...
...
editor/js/
CmdSetMaterialMap
.js
→
editor/js/
commands/SetMaterialMapCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,10 +10,10 @@
* @constructor
*/
CmdSetMaterialMap
=
function
(
object
,
mapName
,
newMap
)
{
SetMaterialMapCommand
=
function
(
object
,
mapName
,
newMap
)
{
C
m
d
.
call
(
this
);
this
.
type
=
'
CmdSetMaterialMap
'
;
C
omman
d
.
call
(
this
);
this
.
type
=
'
SetMaterialMapCommand
'
;
this
.
name
=
'
Set Material.
'
+
mapName
;
this
.
object
=
object
;
...
...
@@ -23,7 +23,7 @@ CmdSetMaterialMap = function ( object, mapName, newMap ) {
};
CmdSetMaterialMap
.
prototype
=
{
SetMaterialMapCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -43,7 +43,7 @@ CmdSetMaterialMap.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
mapName
=
this
.
mapName
;
...
...
@@ -97,7 +97,7 @@ CmdSetMaterialMap.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
mapName
=
json
.
mapName
;
...
...
editor/js/
CmdSetMaterialValue
.js
→
editor/js/
commands/SetMaterialValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetMaterialValue
=
function
(
object
,
attributeName
,
newValue
)
{
SetMaterialValueCommand
=
function
(
object
,
attributeName
,
newValue
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetMaterialValue
'
;
this
.
type
=
'
SetMaterialValueCommand
'
;
this
.
name
=
'
Set Material.
'
+
attributeName
;
this
.
updatable
=
true
;
...
...
@@ -25,7 +25,7 @@ CmdSetMaterialValue = function ( object, attributeName, newValue ) {
};
CmdSetMaterialValue
.
prototype
=
{
SetMaterialValueCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -51,7 +51,7 @@ CmdSetMaterialValue.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
attributeName
=
this
.
attributeName
;
...
...
@@ -64,7 +64,7 @@ CmdSetMaterialValue.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
attributeName
=
json
.
attributeName
;
this
.
oldValue
=
json
.
oldValue
;
...
...
editor/js/
CmdSetPosition
.js
→
editor/js/
commands/SetPositionCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetPosition
=
function
(
object
,
newPosition
,
optionalOldPosition
)
{
SetPositionCommand
=
function
(
object
,
newPosition
,
optionalOldPosition
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetPosition
'
;
this
.
type
=
'
SetPositionCommand
'
;
this
.
name
=
'
Set Position
'
;
this
.
updatable
=
true
;
...
...
@@ -34,7 +34,7 @@ CmdSetPosition = function ( object, newPosition, optionalOldPosition ) {
}
};
CmdSetPosition
.
prototype
=
{
SetPositionCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -60,7 +60,7 @@ CmdSetPosition.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
oldPosition
=
this
.
oldPosition
.
toArray
();
...
...
@@ -72,7 +72,7 @@ CmdSetPosition.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
oldPosition
=
new
THREE
.
Vector3
().
fromArray
(
json
.
oldPosition
);
...
...
editor/js/
CmdSetRotation
.js
→
editor/js/
commands/SetRotationCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetRotation
=
function
(
object
,
newRotation
,
optionalOldRotation
)
{
SetRotationCommand
=
function
(
object
,
newRotation
,
optionalOldRotation
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetRotation
'
;
this
.
type
=
'
SetRotationCommand
'
;
this
.
name
=
'
Set Rotation
'
;
this
.
updatable
=
true
;
...
...
@@ -35,7 +35,7 @@ CmdSetRotation = function ( object, newRotation, optionalOldRotation ) {
};
CmdSetRotation
.
prototype
=
{
SetRotationCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -61,7 +61,7 @@ CmdSetRotation.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
oldRotation
=
this
.
oldRotation
.
toArray
();
...
...
@@ -73,7 +73,7 @@ CmdSetRotation.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
oldRotation
=
new
THREE
.
Euler
().
fromArray
(
json
.
oldRotation
);
...
...
editor/js/
CmdSetScale
.js
→
editor/js/
commands/SetScaleCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetScale
=
function
(
object
,
newScale
,
optionalOldScale
)
{
SetScaleCommand
=
function
(
object
,
newScale
,
optionalOldScale
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetScale
'
;
this
.
type
=
'
SetScaleCommand
'
;
this
.
name
=
'
Set Scale
'
;
this
.
updatable
=
true
;
...
...
@@ -35,7 +35,7 @@ CmdSetScale = function ( object, newScale, optionalOldScale ) {
};
CmdSetScale
.
prototype
=
{
SetScaleCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -61,7 +61,7 @@ CmdSetScale.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
oldScale
=
this
.
oldScale
.
toArray
();
...
...
@@ -73,7 +73,7 @@ CmdSetScale.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
object
=
this
.
editor
.
objectByUuid
(
json
.
objectUuid
);
this
.
oldScale
=
new
THREE
.
Vector3
().
fromArray
(
json
.
oldScale
);
...
...
editor/js/
CmdSetScene
.js
→
editor/js/
commands/SetSceneCommand
.js
浏览文件 @
62ebe779
...
...
@@ -8,25 +8,25 @@
* @constructor
*/
CmdSetScene
=
function
(
scene
)
{
SetSceneCommand
=
function
(
scene
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetScene
'
;
this
.
type
=
'
SetSceneCommand
'
;
this
.
name
=
'
Set Scene
'
;
this
.
cmdArray
=
[];
if
(
scene
!==
undefined
)
{
this
.
cmdArray
.
push
(
new
CmdSetUui
d
(
this
.
editor
.
scene
,
scene
.
uuid
)
);
this
.
cmdArray
.
push
(
new
CmdSetValue
(
this
.
editor
.
scene
,
'
name
'
,
scene
.
name
)
);
this
.
cmdArray
.
push
(
new
CmdSetValue
(
this
.
editor
.
scene
,
'
userData
'
,
JSON
.
parse
(
JSON
.
stringify
(
scene
.
userData
)
)
)
);
this
.
cmdArray
.
push
(
new
SetUuidComman
d
(
this
.
editor
.
scene
,
scene
.
uuid
)
);
this
.
cmdArray
.
push
(
new
SetValueCommand
(
this
.
editor
.
scene
,
'
name
'
,
scene
.
name
)
);
this
.
cmdArray
.
push
(
new
SetValueCommand
(
this
.
editor
.
scene
,
'
userData
'
,
JSON
.
parse
(
JSON
.
stringify
(
scene
.
userData
)
)
)
);
while
(
scene
.
children
.
length
>
0
)
{
var
child
=
scene
.
children
.
pop
();
this
.
cmdArray
.
push
(
new
CmdAddObject
(
child
)
);
this
.
cmdArray
.
push
(
new
AddObjectCommand
(
child
)
);
}
...
...
@@ -34,7 +34,7 @@ CmdSetScene = function ( scene ) {
};
CmdSetScene
.
prototype
=
{
SetSceneCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -68,7 +68,7 @@ CmdSetScene.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
var
cmds
=
[];
for
(
var
i
=
0
;
i
<
this
.
cmdArray
.
length
;
i
++
)
{
...
...
@@ -84,7 +84,7 @@ CmdSetScene.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
var
cmds
=
json
.
cmds
;
for
(
var
i
=
0
;
i
<
cmds
.
length
;
i
++
)
{
...
...
editor/js/
CmdSetScriptValue
.js
→
editor/js/
commands/SetScriptValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -12,11 +12,11 @@
* @constructor
*/
CmdSetScriptValue
=
function
(
object
,
script
,
attributeName
,
newValue
,
cursorPosition
)
{
SetScriptValueCommand
=
function
(
object
,
script
,
attributeName
,
newValue
,
cursorPosition
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetScriptValue
'
;
this
.
type
=
'
SetScriptValueCommand
'
;
this
.
name
=
'
Set Script.
'
+
attributeName
;
this
.
updatable
=
true
;
...
...
@@ -30,7 +30,7 @@ CmdSetScriptValue = function ( object, script, attributeName, newValue, cursorPo
};
CmdSetScriptValue
.
prototype
=
{
SetScriptValueCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -59,7 +59,7 @@ CmdSetScriptValue.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
index
=
this
.
editor
.
scripts
[
this
.
object
.
uuid
].
indexOf
(
this
.
script
);
...
...
@@ -74,7 +74,7 @@ CmdSetScriptValue.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
oldValue
=
json
.
oldValue
;
this
.
newValue
=
json
.
newValue
;
...
...
editor/js/
CmdSetUui
d.js
→
editor/js/
commands/SetUuidComman
d.js
浏览文件 @
62ebe779
...
...
@@ -9,11 +9,11 @@
* @constructor
*/
CmdSetUui
d
=
function
(
object
,
newUuid
)
{
SetUuidComman
d
=
function
(
object
,
newUuid
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetUui
d
'
;
this
.
type
=
'
SetUuidComman
d
'
;
this
.
name
=
'
Update UUID
'
;
this
.
object
=
object
;
...
...
@@ -23,7 +23,7 @@ CmdSetUuid = function ( object, newUuid ) {
};
CmdSetUui
d
.
prototype
=
{
SetUuidComman
d
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -43,7 +43,7 @@ CmdSetUuid.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
oldUuid
=
this
.
oldUuid
;
output
.
newUuid
=
this
.
newUuid
;
...
...
@@ -54,7 +54,7 @@ CmdSetUuid.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
oldUuid
=
json
.
oldUuid
;
this
.
newUuid
=
json
.
newUuid
;
...
...
editor/js/
CmdSetValue
.js
→
editor/js/
commands/SetValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -10,11 +10,11 @@
* @constructor
*/
CmdSetValue
=
function
(
object
,
attributeName
,
newValue
)
{
SetValueCommand
=
function
(
object
,
attributeName
,
newValue
)
{
C
m
d
.
call
(
this
);
C
omman
d
.
call
(
this
);
this
.
type
=
'
CmdSetValue
'
;
this
.
type
=
'
SetValueCommand
'
;
this
.
name
=
'
Set
'
+
attributeName
;
this
.
updatable
=
true
;
...
...
@@ -25,7 +25,7 @@ CmdSetValue = function ( object, attributeName, newValue ) {
};
CmdSetValue
.
prototype
=
{
SetValueCommand
.
prototype
=
{
execute
:
function
()
{
...
...
@@ -51,7 +51,7 @@ CmdSetValue.prototype = {
toJSON
:
function
()
{
var
output
=
C
m
d
.
prototype
.
toJSON
.
call
(
this
);
var
output
=
C
omman
d
.
prototype
.
toJSON
.
call
(
this
);
output
.
objectUuid
=
this
.
object
.
uuid
;
output
.
attributeName
=
this
.
attributeName
;
...
...
@@ -64,7 +64,7 @@ CmdSetValue.prototype = {
fromJSON
:
function
(
json
)
{
C
m
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
C
omman
d
.
prototype
.
fromJSON
.
call
(
this
,
json
);
this
.
attributeName
=
json
.
attributeName
;
this
.
oldValue
=
json
.
oldValue
;
...
...
editor/js/libs/ui.three.js
浏览文件 @
62ebe779
...
...
@@ -158,12 +158,12 @@ UI.Outliner = function ( editor ) {
if
(
item
.
nextSibling
===
null
)
{
editor
.
execute
(
new
CmdMoveObject
(
object
,
editor
.
scene
)
);
editor
.
execute
(
new
MoveObjectCommand
(
object
,
editor
.
scene
)
);
}
else
{
var
nextObject
=
scene
.
getObjectById
(
item
.
nextSibling
.
value
);
editor
.
execute
(
new
CmdMoveObject
(
object
,
nextObject
.
parent
,
nextObject
)
);
editor
.
execute
(
new
MoveObjectCommand
(
object
,
nextObject
.
parent
,
nextObject
)
);
}
...
...
test/unit/editor/Test
CmdAddObjectAndCmdRemoveObject
.js
→
test/unit/editor/Test
AddObjectCommandAndRemoveObjectCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdAddObjectAndCmdRemoveObject
"
);
module
(
"
AddObjectCommandAndRemoveObjectCommand
"
);
test
(
"
Test
CmdAddObject and CmdRemoveObject
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
AddObjectCommand and RemoveObjectCommand
(Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
...
...
@@ -19,7 +19,7 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
objects
.
map
(
function
(
object
)
{
// Test Add
var
cmd
=
new
CmdAddObject
(
object
);
var
cmd
=
new
AddObjectCommand
(
object
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -35,7 +35,7 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
// Test Remove
var
cmd
=
new
CmdRemoveObject
(
object
);
var
cmd
=
new
RemoveObjectCommand
(
object
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdAddScript
.js
→
test/unit/editor/Test
AddScriptCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdAddScript
"
);
module
(
"
AddScriptCommand
"
);
test
(
"
Test
CmdAddScript
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
AddScriptCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
...
...
@@ -21,7 +21,7 @@ test( "Test CmdAddScript (Undo and Redo)", function() {
// add objects to editor
objects
.
map
(
function
(
item
)
{
editor
.
execute
(
new
CmdAddObject
(
item
)
);
editor
.
execute
(
new
AddObjectCommand
(
item
)
);
}
);
ok
(
editor
.
scene
.
children
.
length
==
2
,
"
OK, the box and the sphere have been added
"
);
...
...
@@ -29,7 +29,7 @@ test( "Test CmdAddScript (Undo and Redo)", function() {
// add scripts to the objects
for
(
var
i
=
0
;
i
<
scripts
.
length
;
i
++
)
{
var
cmd
=
new
CmdAddScript
(
objects
[
i
],
scripts
[
i
]
);
var
cmd
=
new
AddScriptCommand
(
objects
[
i
],
scripts
[
i
]
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/TestMassUndoAndRedo.js
浏览文件 @
62ebe779
...
...
@@ -16,7 +16,7 @@ test( "MassUndoAndRedo (stress test)", function() {
while
(
i
<
MAX_OBJECTS
)
{
var
object
=
aSphere
(
'
Sphere #
'
+
i
);
var
cmd
=
new
CmdAddObject
(
object
);
var
cmd
=
new
AddObjectCommand
(
object
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdMoveObject
.js
→
test/unit/editor/Test
MoveObjectCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdMoveObject
"
);
module
(
"
MoveObjectCommand
"
);
test
(
"
Test
CmdMoveObject
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
MoveObjectCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
...
...
@@ -15,15 +15,15 @@ test( "Test CmdMoveObject (Undo and Redo)", function() {
var
anakinSkywalker
=
aSphere
(
anakinsName
);
var
lukeSkywalker
=
aBox
(
lukesName
);
editor
.
execute
(
new
CmdAddObject
(
anakinSkywalker
)
);
editor
.
execute
(
new
CmdAddObject
(
lukeSkywalker
)
);
editor
.
execute
(
new
AddObjectCommand
(
anakinSkywalker
)
);
editor
.
execute
(
new
AddObjectCommand
(
lukeSkywalker
)
);
ok
(
anakinSkywalker
.
parent
.
name
==
"
Scene
"
,
"
OK, Anakin's parent is 'Scene'
"
);
ok
(
lukeSkywalker
.
parent
.
name
==
"
Scene
"
,
"
OK, Luke's parent is 'Scene'
"
);
// Tell Luke, Anakin is his father
editor
.
execute
(
new
CmdMoveObject
(
lukeSkywalker
,
anakinSkywalker
)
);
editor
.
execute
(
new
MoveObjectCommand
(
lukeSkywalker
,
anakinSkywalker
)
);
ok
(
true
===
true
,
"
(Luke has been told who his father is)
"
);
ok
(
anakinSkywalker
.
parent
.
name
==
"
Scene
"
,
"
OK, Anakin's parent is still 'Scene'
"
);
...
...
test/unit/editor/Test
CmdMultiCmds
.js
→
test/unit/editor/Test
MultiCmdsCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdMultiCmds
"
);
module
(
"
MultiCmdsCommand
"
);
test
(
"
Test
CmdMultiCmds
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
MultiCmdsCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
var
box
=
aBox
(
'
Multi Command Box
'
);
...
...
@@ -13,17 +13,17 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
var
boxGeometry2
=
{
geometry
:
{
parameters
:
{
width
:
50
,
height
:
51
,
depth
:
52
,
widthSegments
:
7
,
heightSegments
:
8
,
depthSegments
:
9
}
}
};
var
boxGeometries
=
[
getGeometry
(
"
BoxGeometry
"
,
boxGeometry1
),
getGeometry
(
"
BoxGeometry
"
,
boxGeometry2
)
];
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
// setup first multi commands
var
firstMultiCmds
=
[
new
CmdSetGeometry
(
box
,
boxGeometries
[
0
]
),
new
CmdSetPosition
(
box
,
new
THREE
.
Vector3
(
1
,
2
,
3
)
),
new
CmdSetRotation
(
box
,
new
THREE
.
Euler
(
0.1
,
0.2
,
0.2
)
),
new
CmdSetScale
(
box
,
new
THREE
.
Vector3
(
1.1
,
1.2
,
1.3
)
)
new
SetGeometryCommand
(
box
,
boxGeometries
[
0
]
),
new
SetPositionCommand
(
box
,
new
THREE
.
Vector3
(
1
,
2
,
3
)
),
new
SetRotationCommand
(
box
,
new
THREE
.
Euler
(
0.1
,
0.2
,
0.2
)
),
new
SetScaleCommand
(
box
,
new
THREE
.
Vector3
(
1.1
,
1.2
,
1.3
)
)
];
...
...
@@ -33,7 +33,7 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
}
);
var
firstMultiCmd
=
new
CmdMultiCmds
(
firstMultiCmds
);
var
firstMultiCmd
=
new
MultiCmdsCommand
(
firstMultiCmds
);
firstMultiCmd
.
updatable
=
false
;
editor
.
execute
(
firstMultiCmd
);
...
...
@@ -41,10 +41,10 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
// setup second multi commands
var
secondMultiCmds
=
[
new
CmdSetGeometry
(
box
,
boxGeometries
[
1
]
),
new
CmdSetPosition
(
box
,
new
THREE
.
Vector3
(
4
,
5
,
6
)
),
new
CmdSetRotation
(
box
,
new
THREE
.
Euler
(
0.4
,
0.5
,
0.6
)
),
new
CmdSetScale
(
box
,
new
THREE
.
Vector3
(
1.4
,
1.5
,
1.6
)
)
new
SetGeometryCommand
(
box
,
boxGeometries
[
1
]
),
new
SetPositionCommand
(
box
,
new
THREE
.
Vector3
(
4
,
5
,
6
)
),
new
SetRotationCommand
(
box
,
new
THREE
.
Euler
(
0.4
,
0.5
,
0.6
)
),
new
SetScaleCommand
(
box
,
new
THREE
.
Vector3
(
1.4
,
1.5
,
1.6
)
)
];
...
...
@@ -54,7 +54,7 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
}
);
var
secondMultiCmd
=
new
CmdMultiCmds
(
secondMultiCmds
);
var
secondMultiCmd
=
new
MultiCmdsCommand
(
secondMultiCmds
);
secondMultiCmd
.
updatable
=
false
;
editor
.
execute
(
secondMultiCmd
);
...
...
test/unit/editor/TestNegativeCases.js
浏览文件 @
62ebe779
...
...
@@ -21,7 +21,7 @@ test( "Test unwanted situations ", function() {
var
box
=
aBox
();
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/TestNestedDoUndoRedo.js
浏览文件 @
62ebe779
...
...
@@ -32,16 +32,16 @@ test( "Test nested Do's, Undo's and Redo's", function() {
mesh
.
scale
.
z
=
initScaleZ
;
// let's begin
editor
.
execute
(
new
CmdAddObject
(
mesh
)
);
editor
.
execute
(
new
AddObjectCommand
(
mesh
)
);
var
newPos
=
new
THREE
.
Vector3
(
initPosX
+
100
,
initPosY
,
initPosZ
);
editor
.
execute
(
new
CmdSetPosition
(
mesh
,
newPos
)
);
editor
.
execute
(
new
SetPositionCommand
(
mesh
,
newPos
)
);
var
newRotation
=
new
THREE
.
Euler
(
initRotationX
,
initRotationY
+
1000
,
initRotationZ
);
editor
.
execute
(
new
CmdSetRotation
(
mesh
,
newRotation
)
);
editor
.
execute
(
new
SetRotationCommand
(
mesh
,
newRotation
)
);
var
newScale
=
new
THREE
.
Vector3
(
initScaleX
,
initScaleY
,
initScaleZ
+
10000
);
editor
.
execute
(
new
CmdSetScale
(
mesh
,
newScale
)
);
editor
.
execute
(
new
SetScaleCommand
(
mesh
,
newScale
)
);
/* full check */
...
...
@@ -81,7 +81,7 @@ test( "Test nested Do's, Undo's and Redo's", function() {
editor
.
redo
();
// translation redone
editor
.
redo
();
// rotation redone
editor
.
execute
(
new
CmdRemoveObject
(
mesh
)
);
editor
.
execute
(
new
RemoveObjectCommand
(
mesh
)
);
ok
(
editor
.
scene
.
children
.
length
==
0
,
"
OK, object removal was successful
"
);
editor
.
undo
();
// removal undone
...
...
test/unit/editor/Test
CmdRemoveScript
.js
→
test/unit/editor/Test
RemoveScriptCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdRemoveScript
"
);
module
(
"
RemoveScriptCommand
"
);
test
(
"
Test
CmdRemoveScript
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
RemoveScriptCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
...
...
@@ -21,7 +21,7 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
// add objects to editor
objects
.
map
(
function
(
item
)
{
editor
.
execute
(
new
CmdAddObject
(
item
)
);
editor
.
execute
(
new
AddObjectCommand
(
item
)
);
}
);
ok
(
editor
.
scene
.
children
.
length
==
2
,
"
OK, the box and the sphere have been added
"
);
...
...
@@ -29,7 +29,7 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
// add scripts to the objects
for
(
var
i
=
0
;
i
<
scripts
.
length
;
i
++
)
{
var
cmd
=
new
CmdAddScript
(
objects
[
i
],
scripts
[
i
]
);
var
cmd
=
new
AddScriptCommand
(
objects
[
i
],
scripts
[
i
]
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -37,7 +37,7 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
for
(
var
i
=
0
;
i
<
scripts
.
length
;
i
++
)
{
var
cmd
=
new
CmdRemoveScript
(
objects
[
i
],
scripts
[
i
]
);
var
cmd
=
new
RemoveScriptCommand
(
objects
[
i
],
scripts
[
i
]
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/TestSerialization.js
浏览文件 @
62ebe779
...
...
@@ -25,7 +25,7 @@ test( "Test Serialization", function( assert ) {
var
box
=
aBox
(
'
The Box
'
);
// Test Add
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -41,10 +41,10 @@ test( "Test Serialization", function( assert ) {
// Test Add
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
editor
.
execute
(
cmd
);
var
cmd
=
new
CmdAddScript
(
box
,
{
"
name
"
:
"
test
"
,
"
source
"
:
"
console.log(
\"
hello world
\"
);
"
}
);
var
cmd
=
new
AddScriptCommand
(
box
,
{
"
name
"
:
"
test
"
,
"
source
"
:
"
console.log(
\"
hello world
\"
);
"
}
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -61,11 +61,11 @@ test( "Test Serialization", function( assert ) {
var
anakinSkywalker
=
aSphere
(
anakinsName
);
var
lukeSkywalker
=
aBox
(
lukesName
);
editor
.
execute
(
new
CmdAddObject
(
anakinSkywalker
)
);
editor
.
execute
(
new
CmdAddObject
(
lukeSkywalker
)
);
editor
.
execute
(
new
AddObjectCommand
(
anakinSkywalker
)
);
editor
.
execute
(
new
AddObjectCommand
(
lukeSkywalker
)
);
// Tell Luke, Anakin is his father
editor
.
execute
(
new
CmdMoveObject
(
lukeSkywalker
,
anakinSkywalker
)
);
editor
.
execute
(
new
MoveObjectCommand
(
lukeSkywalker
,
anakinSkywalker
)
);
return
"
moveObject
"
;
...
...
@@ -74,15 +74,15 @@ test( "Test Serialization", function( assert ) {
var
removeScript
=
function
()
{
var
box
=
aBox
(
'
Box with no script
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
script
=
{
"
name
"
:
"
test
"
,
"
source
"
:
"
console.log(
\"
hello world
\"
);
"
}
;
var
cmd
=
new
CmdAddScript
(
box
,
script
);
var
cmd
=
new
AddScriptCommand
(
box
,
script
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
cmd
=
new
CmdRemoveScript
(
box
,
script
);
cmd
=
new
RemoveScriptCommand
(
box
,
script
);
editor
.
execute
(
cmd
);
return
"
removeScript
"
;
...
...
@@ -93,8 +93,8 @@ test( "Test Serialization", function( assert ) {
var
pointLight
=
aPointlight
(
"
The light Light
"
);
editor
.
execute
(
new
CmdAddObject
(
pointLight
)
);
var
cmd
=
new
CmdSetColor
(
pointLight
,
'
color
'
,
green
);
editor
.
execute
(
new
AddObjectCommand
(
pointLight
)
);
var
cmd
=
new
SetColorCommand
(
pointLight
,
'
color
'
,
green
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -107,9 +107,9 @@ test( "Test Serialization", function( assert ) {
var
box
=
aBox
(
'
Guinea Pig
'
);
// default ( 100, 100, 100, 1, 1, 1 )
var
boxGeometry
=
{
geometry
:
{
parameters
:
{
width
:
200
,
height
:
201
,
depth
:
202
,
widthSegments
:
2
,
heightSegments
:
3
,
depthSegments
:
4
}
}
};
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
cmd
=
new
CmdSetGeometry
(
box
,
getGeometry
(
"
BoxGeometry
"
,
boxGeometry
)
);
var
cmd
=
new
SetGeometryCommand
(
box
,
getGeometry
(
"
BoxGeometry
"
,
boxGeometry
)
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -120,9 +120,9 @@ test( "Test Serialization", function( assert ) {
var
setGeometryValue
=
function
()
{
var
box
=
aBox
(
'
Geometry Value Box
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
cmd
=
new
CmdSetGeometryValue
(
box
,
'
uuid
'
,
THREE
.
Math
.
generateUUID
()
);
cmd
=
new
SetGeometryValueCommand
(
box
,
'
uuid
'
,
THREE
.
Math
.
generateUUID
()
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -133,10 +133,10 @@ test( "Test Serialization", function( assert ) {
var
setMaterial
=
function
()
{
var
sphere
=
aSphere
(
'
The Sun
'
);
editor
.
execute
(
new
CmdAddObject
(
sphere
)
);
editor
.
execute
(
new
AddObjectCommand
(
sphere
)
);
var
material
=
new
THREE
[
'
MeshPhongMaterial
'
]();
var
cmd
=
new
CmdSetMaterial
(
sphere
,
material
);
var
cmd
=
new
SetMaterialCommand
(
sphere
,
material
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -147,9 +147,9 @@ test( "Test Serialization", function( assert ) {
var
setMaterialColor
=
function
()
{
var
box
=
aBox
(
'
Box with colored material
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
cmd
=
new
CmdSetMaterialColor
(
box
,
'
color
'
,
green
);
var
cmd
=
new
SetMaterialColorCommand
(
box
,
'
color
'
,
green
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -160,7 +160,7 @@ test( "Test Serialization", function( assert ) {
var
setMaterialMap
=
function
()
{
var
sphere
=
aSphere
(
'
Sphere with texture
'
);
editor
.
execute
(
new
CmdAddObject
(
sphere
)
);
editor
.
execute
(
new
AddObjectCommand
(
sphere
)
);
// dirt.png
var
data
=
'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpDMjYxMEI4MzVENDMxMUU1OTdEQUY4QkNGNUVENjg4MyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpDMjYxMEI4NDVENDMxMUU1OTdEQUY4QkNGNUVENjg4MyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkMyNjEwQjgxNUQ0MzExRTU5N0RBRjhCQ0Y1RUQ2ODgzIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkMyNjEwQjgyNUQ0MzExRTU5N0RBRjhCQ0Y1RUQ2ODgzIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+txizaQAAABVQTFRFh4eHbGxsdFhEWT0puYVclmxKeVU6ppwr+AAAAHtJREFUeNosjgEWBCEIQplFuP+RB5h9lZn2EZxkLzC3D1YSgSlmk7i0ctzDZNBz/VSoX1KwjlFI8WmA2R7JqUa0LJJcd1rLNWRRaMyi+3Y16qMKHhdE48XLsDyHKJ0nSMazY1fxHyriXxV584tmEedcfGNrA/5cmK8AAwCT9ATehDDyzwAAAABJRU5ErkJggg==
'
;
...
...
@@ -170,7 +170,7 @@ test( "Test Serialization", function( assert ) {
var
texture
=
new
THREE
.
Texture
(
img
,
'
map
'
);
texture
.
sourceFile
=
'
dirt.png
'
;
var
cmd
=
new
CmdSetMaterialMap
(
sphere
,
'
map
'
,
texture
);
var
cmd
=
new
SetMaterialMapCommand
(
sphere
,
'
map
'
,
texture
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -181,9 +181,9 @@ test( "Test Serialization", function( assert ) {
var
setMaterialValue
=
function
()
{
var
box
=
aBox
(
'
Box with values
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
cmd
=
new
CmdSetMaterialValue
(
box
,
'
name
'
,
'
Bravo
'
);
var
cmd
=
new
SetMaterialValueCommand
(
box
,
'
name
'
,
'
Bravo
'
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -194,10 +194,10 @@ test( "Test Serialization", function( assert ) {
var
setPosition
=
function
()
{
var
sphere
=
aSphere
(
'
Sphere with position
'
);
editor
.
execute
(
new
CmdAddObject
(
sphere
)
);
editor
.
execute
(
new
AddObjectCommand
(
sphere
)
);
var
newPosition
=
new
THREE
.
Vector3
(
101
,
202
,
303
);
var
cmd
=
new
CmdSetPosition
(
sphere
,
newPosition
);
var
cmd
=
new
SetPositionCommand
(
sphere
,
newPosition
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -208,10 +208,10 @@ test( "Test Serialization", function( assert ) {
var
setRotation
=
function
()
{
var
box
=
aBox
(
'
Box with rotation
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
newRotation
=
new
THREE
.
Euler
(
0.3
,
-
1.7
,
2
);
var
cmd
=
new
CmdSetRotation
(
box
,
newRotation
);
var
cmd
=
new
SetRotationCommand
(
box
,
newRotation
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -222,10 +222,10 @@ test( "Test Serialization", function( assert ) {
var
setScale
=
function
()
{
var
sphere
=
aSphere
(
'
Sphere with scale
'
);
editor
.
execute
(
new
CmdAddObject
(
sphere
)
);
editor
.
execute
(
new
AddObjectCommand
(
sphere
)
);
var
newScale
=
new
THREE
.
Vector3
(
1.2
,
3.3
,
4.6
);
var
cmd
=
new
CmdSetScale
(
sphere
,
newScale
);
var
cmd
=
new
SetScaleCommand
(
sphere
,
newScale
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -236,12 +236,12 @@ test( "Test Serialization", function( assert ) {
var
setScriptValue
=
function
()
{
var
box
=
aBox
(
'
Box with script
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
script
=
{
name
:
"
Alert
"
,
source
:
"
alert( null );
"
};
editor
.
execute
(
new
CmdAddScript
(
box
,
script
)
);
editor
.
execute
(
new
AddScriptCommand
(
box
,
script
)
);
var
newScript
=
{
name
:
"
Console
"
,
source
:
"
console.log( null );
"
};
var
cmd
=
new
CmdSetScriptValue
(
box
,
script
,
'
source
'
,
newScript
.
source
,
0
);
var
cmd
=
new
SetScriptValueCommand
(
box
,
script
,
'
source
'
,
newScript
.
source
,
0
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -252,9 +252,9 @@ test( "Test Serialization", function( assert ) {
var
setUuid
=
function
()
{
var
sphere
=
aSphere
(
'
Sphere with UUID
'
);
editor
.
execute
(
new
CmdAddObject
(
sphere
)
);
editor
.
execute
(
new
AddObjectCommand
(
sphere
)
);
var
cmd
=
new
CmdSetUui
d
(
sphere
,
THREE
.
Math
.
generateUUID
()
);
var
cmd
=
new
SetUuidComman
d
(
sphere
,
THREE
.
Math
.
generateUUID
()
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -265,9 +265,9 @@ test( "Test Serialization", function( assert ) {
var
setValue
=
function
()
{
var
box
=
aBox
(
'
Box with value
'
);
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
cmd
=
new
CmdSetValue
(
box
,
'
intensity
'
,
2.3
);
var
cmd
=
new
SetValueCommand
(
box
,
'
intensity
'
,
2.3
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetColor
.js
→
test/unit/editor/Test
SetColorCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,13 +3,13 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetColor
"
);
module
(
"
SetColorCommand
"
);
test
(
"
Test
CmdSetColor
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetColorCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
var
pointLight
=
aPointlight
(
"
The light Light
"
);
editor
.
execute
(
new
CmdAddObject
(
pointLight
)
);
editor
.
execute
(
new
AddObjectCommand
(
pointLight
)
);
var
green
=
12581843
;
// bffbd3
var
blue
=
14152447
;
// d7f2ff
...
...
@@ -19,7 +19,7 @@ test( "Test CmdSetColor (Undo and Redo)", function() {
colors
.
map
(
function
(
color
)
{
var
cmd
=
new
CmdSetColor
(
pointLight
,
'
color
'
,
color
);
var
cmd
=
new
SetColorCommand
(
pointLight
,
'
color
'
,
color
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetGeometry
.js
→
test/unit/editor/Test
SetGeometryCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetGeometry
"
);
module
(
"
SetGeometryCommand
"
);
test
(
"
Test
CmdSetGeometry
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetGeometryCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
...
...
@@ -17,13 +17,13 @@ test( "Test CmdSetGeometry (Undo and Redo)", function() {
// add the object
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
for
(
var
i
=
0
;
i
<
geometryParams
.
length
;
i
++
)
{
var
cmd
=
new
CmdSetGeometry
(
box
,
getGeometry
(
"
BoxGeometry
"
,
geometryParams
[
i
]
)
);
var
cmd
=
new
SetGeometryCommand
(
box
,
getGeometry
(
"
BoxGeometry
"
,
geometryParams
[
i
]
)
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetGeometryValue
.js
→
test/unit/editor/Test
SetGeometryValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetGeometryValue
"
);
module
(
"
SetGeometryValueCommand
"
);
test
(
"
Test
CmdSetGeometryValue
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetGeometryValueCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
var
box
=
aBox
(
'
The Box
'
);
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -25,7 +25,7 @@ test( "Test CmdSetGeometryValue (Undo and Redo)", function() {
keys
.
map
(
function
(
key
)
{
cmd
=
new
CmdSetGeometryValue
(
box
,
key
,
testData
[
i
][
key
]
);
cmd
=
new
SetGeometryValueCommand
(
box
,
key
,
testData
[
i
][
key
]
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetMaterialColor
.js
→
test/unit/editor/Test
SetMaterialColorCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetMaterialColor
"
);
module
(
"
SetMaterialColorCommand
"
);
test
(
"
Test for
CmdSetMaterialColor
(Undo and Redo)
"
,
function
()
{
test
(
"
Test for
SetMaterialColorCommand
(Undo and Redo)
"
,
function
()
{
// Setup scene
var
editor
=
new
Editor
();
var
box
=
aBox
();
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -25,7 +25,7 @@ test( "Test for CmdSetMaterialColor (Undo and Redo)", function() {
colors
.
map
(
function
(
color
)
{
var
cmd
=
new
CmdSetMaterialColor
(
box
,
attributeName
,
color
);
var
cmd
=
new
SetMaterialColorCommand
(
box
,
attributeName
,
color
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetMaterial
.js
→
test/unit/editor/Test
SetMaterialCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetMaterial
"
);
module
(
"
SetMaterialCommand
"
);
test
(
"
Test for
CmdSetMaterial
(Undo and Redo)
"
,
function
()
{
test
(
"
Test for
SetMaterialCommand
(Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
var
box
=
aBox
(
'
Material girl in a material world
'
);
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -31,7 +31,7 @@ test( "Test for CmdSetMaterial (Undo and Redo)", function() {
materialClasses
.
map
(
function
(
materialClass
)
{
material
=
new
THREE
[
materialClass
]();
editor
.
execute
(
new
CmdSetMaterial
(
box
,
material
)
);
editor
.
execute
(
new
SetMaterialCommand
(
box
,
material
)
);
}
);
...
...
test/unit/editor/Test
CmdSetMaterialMap
.js
→
test/unit/editor/Test
SetMaterialMapCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetMaterialMap
"
);
module
(
"
SetMaterialMapCommand
"
);
test
(
"
Test for
CmdSetMaterialMap
(Undo and Redo)
"
,
function
()
{
test
(
"
Test for
SetMaterialMapCommand
(Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
var
box
=
aBox
(
'
Material mapped box
'
);
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -47,7 +47,7 @@ test( "Test for CmdSetMaterialMap (Undo and Redo)", function() {
// apply the textures
textures
.
map
(
function
(
texture
)
{
var
cmd
=
new
CmdSetMaterialMap
(
box
,
mapName
,
texture
);
var
cmd
=
new
SetMaterialMapCommand
(
box
,
mapName
,
texture
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetMaterialValue
.js
→
test/unit/editor/Test
SetMaterialValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetMaterialValue
"
);
module
(
"
SetMaterialValueCommand
"
);
test
(
"
Test for
CmdSetMaterialValue
(Undo and Redo)
"
,
function
()
{
test
(
"
Test for
SetMaterialValueCommand
(Undo and Redo)
"
,
function
()
{
// setup scene
var
editor
=
new
Editor
();
var
box
=
aBox
();
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -39,7 +39,7 @@ test( "Test for CmdSetMaterialValue (Undo and Redo)", function() {
testData
[
attributeName
].
map
(
function
(
value
)
{
var
cmd
=
new
CmdSetMaterialValue
(
box
,
attributeName
,
value
);
var
cmd
=
new
SetMaterialValueCommand
(
box
,
attributeName
,
value
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetPosition
.js
→
test/unit/editor/Test
SetPositionCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,13 +3,13 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetPosition
"
);
module
(
"
SetPositionCommand
"
);
test
(
"
Test
CmdSetPosition
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetPositionCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
var
box
=
aBox
();
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
editor
.
execute
(
cmd
);
var
positions
=
[
...
...
@@ -23,7 +23,7 @@ test( "Test CmdSetPosition (Undo and Redo)", function() {
positions
.
map
(
function
(
position
)
{
var
newPosition
=
new
THREE
.
Vector3
(
position
.
x
,
position
.
y
,
position
.
z
);
var
cmd
=
new
CmdSetPosition
(
box
,
newPosition
);
var
cmd
=
new
SetPositionCommand
(
box
,
newPosition
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetRotation
.js
→
test/unit/editor/Test
SetRotationCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetRotation
"
);
module
(
"
SetRotationCommand
"
);
test
(
"
Test
CmdSetRotation
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetRotationCommand
(Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
var
box
=
aBox
();
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
var
rotations
=
[
...
...
@@ -25,7 +25,7 @@ test( "Test CmdSetRotation (Undo and Redo)", function() {
rotations
.
map
(
function
(
rotation
)
{
var
newRotation
=
new
THREE
.
Euler
(
rotation
.
x
,
rotation
.
y
,
rotation
.
z
);
var
cmd
=
new
CmdSetRotation
(
box
,
newRotation
);
var
cmd
=
new
SetRotationCommand
(
box
,
newRotation
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetScale
.js
→
test/unit/editor/Test
SetScaleCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,14 +3,14 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetScale
"
);
module
(
"
SetScaleCommand
"
);
test
(
"
Test
CmdSetScale
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetScaleCommand
(Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
var
box
=
aBox
();
editor
.
execute
(
new
CmdAddObject
(
box
)
);
editor
.
execute
(
new
AddObjectCommand
(
box
)
);
// scales
...
...
@@ -25,7 +25,7 @@ test( "Test CmdSetScale (Undo and Redo)", function() {
scales
.
map
(
function
(
scale
)
{
var
newScale
=
new
THREE
.
Vector3
(
scale
.
x
,
scale
.
y
,
scale
.
z
);
var
cmd
=
new
CmdSetScale
(
box
,
newScale
);
var
cmd
=
new
SetScaleCommand
(
box
,
newScale
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetScene
.js
→
test/unit/editor/Test
SetSceneCommand
.js
浏览文件 @
62ebe779
...
...
@@ -5,7 +5,7 @@
module
(
"
TestCmdSetScene
"
);
test
(
"
Test for
CmdSetScene
(Undo and Redo)
"
,
function
()
{
test
(
"
Test for
SetSceneCommand
(Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
...
...
@@ -16,7 +16,7 @@ test( "Test for CmdSetScene (Undo and Redo)", function() {
var
scenes
=
objects
.
map
(
function
(
object
)
{
editor
=
new
Editor
();
var
cmd
=
new
CmdAddObject
(
object
);
var
cmd
=
new
AddObjectCommand
(
object
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
return
{
obj
:
object
,
exportedData
:
exportScene
(
editor
)
};
...
...
@@ -29,7 +29,7 @@ test( "Test for CmdSetScene (Undo and Redo)", function() {
scenes
.
map
(
function
(
scene
)
{
var
importedScene
=
importScene
(
scene
.
exportedData
);
var
cmd
=
new
CmdSetScene
(
importedScene
);
var
cmd
=
new
SetSceneCommand
(
importedScene
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetScriptValue
.js
→
test/unit/editor/Test
SetScriptValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,20 +3,20 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetScriptValue
"
);
module
(
"
SetScriptValueCommand
"
);
test
(
"
Test
CmdSetScriptValue
for source (Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetScriptValueCommand
for source (Undo and Redo)
"
,
function
()
{
// setup
var
editor
=
new
Editor
();
var
box
=
aBox
(
"
The scripted box
"
);
var
cmd
=
new
CmdAddObject
(
box
);
var
cmd
=
new
AddObjectCommand
(
box
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
var
translateScript
=
{
name
:
"
Translate
"
,
source
:
"
function( update ) {}
"
};
cmd
=
new
CmdAddScript
(
box
,
translateScript
);
cmd
=
new
AddScriptCommand
(
box
,
translateScript
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -34,7 +34,7 @@ test( "Test CmdSetScriptValue for source (Undo and Redo)", function() {
testSourceData
.
map
(
function
(
script
)
{
var
cmd
=
new
CmdSetScriptValue
(
box
,
translateScript
,
'
source
'
,
script
.
source
,
0
);
var
cmd
=
new
SetScriptValueCommand
(
box
,
translateScript
,
'
source
'
,
script
.
source
,
0
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
@@ -57,7 +57,7 @@ test( "Test CmdSetScriptValue for source (Undo and Redo)", function() {
names
.
map
(
function
(
name
)
{
cmd
=
new
CmdSetScriptValue
(
box
,
translateScript
,
'
name
'
,
name
);
cmd
=
new
SetScriptValueCommand
(
box
,
translateScript
,
'
name
'
,
name
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetUui
d.js
→
test/unit/editor/Test
SetUuidComman
d.js
浏览文件 @
62ebe779
...
...
@@ -3,20 +3,20 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetUui
d
"
);
module
(
"
SetUuidComman
d
"
);
test
(
"
Test
CmdSetUui
d (Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetUuidComman
d (Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
var
object
=
aBox
(
'
UUID test box
'
);
editor
.
execute
(
new
CmdAddObject
(
object
)
);
editor
.
execute
(
new
AddObjectCommand
(
object
)
);
var
uuids
=
[
THREE
.
Math
.
generateUUID
(),
THREE
.
Math
.
generateUUID
(),
THREE
.
Math
.
generateUUID
()
];
uuids
.
map
(
function
(
uuid
)
{
var
cmd
=
new
CmdSetUui
d
(
object
,
uuid
);
var
cmd
=
new
SetUuidComman
d
(
object
,
uuid
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
...
...
test/unit/editor/Test
CmdSetValue
.js
→
test/unit/editor/Test
SetValueCommand
.js
浏览文件 @
62ebe779
...
...
@@ -3,9 +3,9 @@
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module
(
"
CmdSetValue
"
);
module
(
"
SetValueCommand
"
);
test
(
"
Test
CmdSetValue
(Undo and Redo)
"
,
function
()
{
test
(
"
Test
SetValueCommand
(Undo and Redo)
"
,
function
()
{
var
editor
=
new
Editor
();
...
...
@@ -18,7 +18,7 @@ test( "Test CmdSetValue (Undo and Redo)", function() {
[
box
,
light
,
cam
].
map
(
function
(
object
)
{
editor
.
execute
(
new
CmdAddObject
(
object
)
);
editor
.
execute
(
new
AddObjectCommand
(
object
)
);
ok
(
0
==
0
,
"
Testing object of type '
"
+
object
.
type
+
"
'
"
);
...
...
@@ -26,12 +26,12 @@ test( "Test CmdSetValue (Undo and Redo)", function() {
if
(
object
[
item
]
!==
undefined
)
{
var
cmd
=
new
CmdSetValue
(
object
,
item
,
valueBefore
);
var
cmd
=
new
SetValueCommand
(
object
,
item
,
valueBefore
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
ok
(
object
[
item
]
==
valueBefore
,
"
OK, the attribute '
"
+
item
+
"
' is correct after first execute (expected: '
"
+
valueBefore
+
"
', actual: '
"
+
object
[
item
]
+
"
')
"
);
var
cmd
=
new
CmdSetValue
(
object
,
item
,
valueAfter
);
var
cmd
=
new
SetValueCommand
(
object
,
item
,
valueAfter
);
cmd
.
updatable
=
false
;
editor
.
execute
(
cmd
);
ok
(
object
[
item
]
==
valueAfter
,
"
OK, the attribute '
"
+
item
+
"
' is correct after second execute (expected: '
"
+
valueAfter
+
"
', actual: '
"
+
object
[
item
]
+
"
')
"
);
...
...
test/unit/unittests_editor.html
浏览文件 @
62ebe779
...
...
@@ -69,52 +69,52 @@
<script
src=
"../../editor/js/History.js"
></script>
<!-- command object classes -->
<script
src=
"../../editor/js/C
m
d.js"
></script>
<script
src=
"../../editor/js/
CmdAddObject
.js"
></script>
<script
src=
"../../editor/js/
CmdAddScript
.js"
></script>
<script
src=
"../../editor/js/
CmdMoveObject
.js"
></script>
<script
src=
"../../editor/js/
CmdMultiCmds
.js"
></script>
<script
src=
"../../editor/js/
CmdRemoveObject
.js"
></script>
<script
src=
"../../editor/js/
CmdRemoveScript
.js"
></script>
<script
src=
"../../editor/js/
CmdSetColor
.js"
></script>
<script
src=
"../../editor/js/
CmdSetGeometry
.js"
></script>
<script
src=
"../../editor/js/
CmdSetGeometryValue
.js"
></script>
<script
src=
"../../editor/js/
CmdSetMaterial
.js"
></script>
<script
src=
"../../editor/js/
CmdSetMaterialColor
.js"
></script>
<script
src=
"../../editor/js/
CmdSetMaterialMap
.js"
></script>
<script
src=
"../../editor/js/
CmdSetMaterialValue
.js"
></script>
<script
src=
"../../editor/js/
CmdSetPosition
.js"
></script>
<script
src=
"../../editor/js/
CmdSetRotation
.js"
></script>
<script
src=
"../../editor/js/
CmdSetScale
.js"
></script>
<script
src=
"../../editor/js/
CmdSetScene
.js"
></script>
<script
src=
"../../editor/js/
CmdSetScriptValue
.js"
></script>
<script
src=
"../../editor/js/
CmdSetUui
d.js"
></script>
<script
src=
"../../editor/js/
CmdSetValue
.js"
></script>
<script
src=
"../../editor/js/C
omman
d.js"
></script>
<script
src=
"../../editor/js/
commands/AddObjectCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/AddScriptCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/MoveObjectCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/MultiCmdsCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/RemoveObjectCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/RemoveScriptCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetColorCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetGeometryCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetGeometryValueCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetMaterialCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetMaterialColorCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetMaterialMapCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetMaterialValueCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetPositionCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetRotationCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetScaleCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetSceneCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetScriptValueCommand
.js"
></script>
<script
src=
"../../editor/js/
commands/SetUuidComman
d.js"
></script>
<script
src=
"../../editor/js/
commands/SetValueCommand
.js"
></script>
<!-- add class-based unit tests below -->
<script
src=
"editor/CommonUtilities.js"
></script>
<!-- Undo-Redo tests -->
<script
src=
"editor/Test
CmdAddObjectAndCmdRemoveObject
.js"
></script>
<script
src=
"editor/Test
CmdAddScript
.js"
></script>
<script
src=
"editor/Test
CmdMoveObject
.js"
></script>
<script
src=
"editor/Test
CmdMultiCmds
.js"
></script>
<script
src=
"editor/Test
CmdRemoveScript
.js"
></script>
<script
src=
"editor/Test
CmdSetColor
.js"
></script>
<script
src=
"editor/Test
CmdSetGeometry
.js"
></script>
<script
src=
"editor/Test
CmdSetGeometryValue
.js"
></script>
<script
src=
"editor/Test
CmdSetMaterial
.js"
></script>
<script
src=
"editor/Test
CmdSetMaterialColor
.js"
></script>
<script
src=
"editor/Test
CmdSetMaterialMap
.js"
></script>
<script
src=
"editor/Test
CmdSetMaterialValue
.js"
></script>
<script
src=
"editor/Test
CmdSetPosition
.js"
></script>
<script
src=
"editor/Test
CmdSetRotation
.js"
></script>
<script
src=
"editor/Test
CmdSetScale
.js"
></script>
<script
src=
"editor/Test
CmdSetScene
.js"
></script>
<script
src=
"editor/Test
CmdSetScriptValue
.js"
></script>
<script
src=
"editor/Test
CmdSetUui
d.js"
></script>
<script
src=
"editor/Test
CmdSetValue
.js"
></script>
<script
src=
"editor/Test
AddObjectCommandAndRemoveObjectCommand
.js"
></script>
<script
src=
"editor/Test
AddScriptCommand
.js"
></script>
<script
src=
"editor/Test
MoveObjectCommand
.js"
></script>
<script
src=
"editor/Test
MultiCmdsCommand
.js"
></script>
<script
src=
"editor/Test
RemoveScriptCommand
.js"
></script>
<script
src=
"editor/Test
SetColorCommand
.js"
></script>
<script
src=
"editor/Test
SetGeometryCommand
.js"
></script>
<script
src=
"editor/Test
SetGeometryValueCommand
.js"
></script>
<script
src=
"editor/Test
SetMaterialCommand
.js"
></script>
<script
src=
"editor/Test
SetMaterialColorCommand
.js"
></script>
<script
src=
"editor/Test
SetMaterialMapCommand
.js"
></script>
<script
src=
"editor/Test
SetMaterialValueCommand
.js"
></script>
<script
src=
"editor/Test
SetPositionCommand
.js"
></script>
<script
src=
"editor/Test
SetRotationCommand
.js"
></script>
<script
src=
"editor/Test
SetScaleCommand
.js"
></script>
<script
src=
"editor/Test
SetSceneCommand
.js"
></script>
<script
src=
"editor/Test
SetScriptValueCommand
.js"
></script>
<script
src=
"editor/Test
SetUuidComman
d.js"
></script>
<script
src=
"editor/Test
SetValueCommand
.js"
></script>
<script
src=
"editor/TestNestedDoUndoRedo.js"
></script>
<script
src=
"editor/TestSerialization.js"
></script>
<script
src=
"editor/TestNegativeCases.js"
></script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录