Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DMDesign
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanda Ghassaei
DMDesign
Commits
88811bb7
Commit
88811bb7
authored
9 years ago
by
Amanda Ghassaei
Browse files
Options
Downloads
Patches
Plain Diff
materials api
parent
17698bb0
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
css/main.css
+1
-0
1 addition, 0 deletions
css/main.css
js/API/MaterialsAPI.js
+8
-3
8 additions, 3 deletions
js/API/MaterialsAPI.js
js/materials/DMAMaterials.js
+19
-11
19 additions, 11 deletions
js/materials/DMAMaterials.js
js/menus/MaterialEditorMenuView.js
+1
-1
1 addition, 1 deletion
js/menus/MaterialEditorMenuView.js
with
29 additions
and
15 deletions
css/main.css
+
1
−
0
View file @
88811bb7
...
...
@@ -587,6 +587,7 @@ label {
border-bottom-width
:
0
;
border-top-width
:
0
;
overflow
:
auto
;
overflow-x
:
hidden
;
resize
:
vertical
;
padding
:
8px
20px
;
font-family
:
Courier
,
monospace
;
...
...
This diff is collapsed.
Click to expand it.
js/API/MaterialsAPI.js
+
8
−
3
View file @
88811bb7
...
...
@@ -3,12 +3,15 @@
*/
define
([
'
materials
'
],
function
(
materials
){
define
([
'
materials
'
,
'
console
'
],
function
(
materials
,
myConsole
){
function
_printGetter
(
output
){
myConsole
.
log
(
output
);
}
return
{
init
:
function
(
json
){
//create a new material
newMaterial
:
function
(
json
){
//create a new material
return
materials
.
newMaterial
(
json
);
//return DMAMaterial object
},
...
...
@@ -17,7 +20,9 @@ define(['materials'], function(materials){
},
getMaterialForId
:
function
(
id
){
return
materials
.
getMaterialForId
(
id
);
var
output
=
materials
.
getMaterialID
(
id
);
_printGetter
(
output
);
return
output
;
},
getMaterials
:
function
(){
...
...
This diff is collapsed.
Click to expand it.
js/materials/DMAMaterials.js
+
19
−
11
View file @
88811bb7
...
...
@@ -3,8 +3,8 @@
*/
//everything is a top level material with a threeMaterial object
define
([
'
underscore
'
,
'
three
'
,
'
appState
'
,
'
lattice
'
,
'
materialsPlist
'
,
'
threeModel
'
,
'
material
'
,
'
compositeMaterial
'
],
function
(
_
,
THREE
,
appState
,
lattice
,
materialsPlist
,
three
,
DMAMaterial
,
DMACompositeMaterial
){
define
([
'
underscore
'
,
'
three
'
,
'
appState
'
,
'
lattice
'
,
'
materialsPlist
'
,
'
threeModel
'
,
'
material
'
,
'
compositeMaterial
'
,
'
console
'
],
function
(
_
,
THREE
,
appState
,
lattice
,
materialsPlist
,
three
,
DMAMaterial
,
DMACompositeMaterial
,
myConsole
){
var
materialsList
=
{
...
...
@@ -15,10 +15,10 @@ define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeMo
color
:
"
#ff0000
"
,
altColor
:
"
#ff0000
"
,
noDelete
:
true
});
}
,
{
silent
:
true
}
);
var
compositeID
=
0
;
var
materialID
=
0
;
var
compositeID
=
1
;
var
materialID
=
1
;
function
getNextCompositeID
(){
return
"
super
"
+
compositeID
++
;
...
...
@@ -40,7 +40,8 @@ define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeMo
function
newMaterial
(
data
,
noAdd
){
function
newMaterial
(
data
,
options
){
options
=
options
||
{};
var
material
,
id
;
if
(
data
.
sparseCells
)
{
id
=
data
.
id
||
getNextCompositeID
();
...
...
@@ -50,9 +51,10 @@ define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeMo
material
=
new
DMAMaterial
(
data
,
id
);
}
if
(
noAdd
)
return
material
;
//in the new material menu, you may init a material before saving changes
if
(
options
.
noAdd
)
return
material
;
//in the new material menu, you may init a material before saving changes
materialsList
[
id
]
=
material
;
if
(
!
options
.
silent
)
myConsole
.
write
(
"
materials.newMaterial(
"
+
JSON
.
stringify
(
material
.
toJSON
())
+
"
}
"
);
return
material
;
}
...
...
@@ -61,11 +63,14 @@ define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeMo
console
.
warn
(
"
this material was never saved
"
);
return
true
;
}
if
(
!
materialsList
[
id
].
canDelete
())
{
console
.
warn
(
"
no delete flag on this material type
"
);
var
material
=
materialsList
[
id
];
if
(
!
material
.
canDelete
())
{
myConsole
.
warn
(
"
noDelete flag on this material type, deleteMaterial operation cancelled
"
);
return
false
;
}
materialsList
[
id
].
destroy
();
myConsole
.
write
(
"
materials.deleteMaterial(
"
+
id
+
"
}
"
);
myConsole
.
log
(
JSON
.
stringify
(
material
.
toJSON
()));
material
.
destroy
();
materialsList
[
id
]
=
null
;
delete
materialsList
[
id
];
//todo check if being used first (instances)
var
deleted
=
true
;
...
...
@@ -90,6 +95,8 @@ define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeMo
edited
=
material
.
set
(
data
);
}
myConsole
.
write
(
"
materials.setMaterial(
"
+
id
+
"
,
"
+
JSON
.
stringify
(
material
.
toJSON
())
+
"
}
"
);
if
(
edited
){
var
allChangedMaterialsList
=
getAllParentComposites
(
id
);
allChangedMaterialsList
.
push
(
id
);
...
...
@@ -217,7 +224,8 @@ define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeMo
var
newMaterials
=
{};
_
.
each
(
definitions
,
function
(
data
,
key
){
data
.
noDelete
=
true
;
newMaterials
[
key
]
=
new
DMAMaterial
(
data
,
key
);
data
.
id
=
key
;
newMaterial
(
data
,
{
silent
:
true
});
});
return
newMaterials
;
}
...
...
This diff is collapsed.
Click to expand it.
js/menus/MaterialEditorMenuView.js
+
1
−
1
View file @
88811bb7
...
...
@@ -26,7 +26,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'materials', 'text!menus/
var
json
=
{};
if
(
material
)
json
=
material
.
toJSON
();
this
.
material
=
materials
.
newMaterial
(
json
,
true
);
this
.
material
=
materials
.
newMaterial
(
json
,
{
noAdd
:
true
}
);
},
getPropertyOwner
:
function
(
$target
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment