summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/javascripts/rectangles/engine/sculpture/move.js1
-rw-r--r--public/assets/javascripts/rectangles/engine/sculpture/resize.js3
-rw-r--r--public/assets/javascripts/rectangles/engine/sculpture/types/_object.js52
-rw-r--r--public/assets/javascripts/rectangles/models/vec3.js18
-rw-r--r--public/assets/javascripts/rectangles/util/measurement.js4
-rw-r--r--public/assets/javascripts/ui/editor/SculptureEditor.js11
-rwxr-xr-xpublic/assets/stylesheets/app.css7
-rw-r--r--views/controls/editor/sculpture.ejs2
8 files changed, 90 insertions, 8 deletions
diff --git a/public/assets/javascripts/rectangles/engine/sculpture/move.js b/public/assets/javascripts/rectangles/engine/sculpture/move.js
index e571c3b..0cbeccd 100644
--- a/public/assets/javascripts/rectangles/engine/sculpture/move.js
+++ b/public/assets/javascripts/rectangles/engine/sculpture/move.js
@@ -83,6 +83,7 @@ Sculpture.move = function(base){
if (editor.permissions.resize) {
Sculpture.resize.move_dots()
+ base.updateOutline()
}
}
diff --git a/public/assets/javascripts/rectangles/engine/sculpture/resize.js b/public/assets/javascripts/rectangles/engine/sculpture/resize.js
index 53b8b2d..5f21d66 100644
--- a/public/assets/javascripts/rectangles/engine/sculpture/resize.js
+++ b/public/assets/javascripts/rectangles/engine/sculpture/resize.js
@@ -180,7 +180,8 @@ Sculpture.resize = new function(){
}
base.move_dots()
-
+ obj.updateOutline()
+
app.controller.sculptureEditor.setDimensions()
}
diff --git a/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js b/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js
index 5dd0aae..2f24ae5 100644
--- a/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js
+++ b/public/assets/javascripts/rectangles/engine/sculpture/types/_object.js
@@ -6,7 +6,8 @@ Sculpture.types.base = Fiber.extend(function(base){
this.id = opt.id || Sculpture.uid("sculpture")
// this.move = new Sculpture.move (this)
this.media = opt.media
- this.naturalDimensions = new vec2(this.media.width, this.media.height)
+ this.naturalDimensions = new vec3(this.media.width, this.media.height, this.media.width)
+ this.dimensions = new vec3(this.media.width, this.media.height, this.media.width)
this.move = new Sculpture.move (this)
this.billboard = true
@@ -14,7 +15,7 @@ Sculpture.types.base = Fiber.extend(function(base){
this.set_scale( opt.scale || this.media.scale || 1.0 )
this.position = new vec2(0,0)
-
+
this.isSculpture = true
},
@@ -25,6 +26,11 @@ Sculpture.types.base = Fiber.extend(function(base){
}
this.dimensions = this.naturalDimensions.clone().mul(this.scale)
},
+ set_depth: function(depth){
+ console.log(this.dimensions.c, this.naturalDimensions.c, depth)
+ this.dimensions.c = depth
+ this.naturalDimensions.c = depth / this.scale
+ },
place: function(opt){
if (opt.data) {
@@ -45,11 +51,16 @@ Sculpture.types.base = Fiber.extend(function(base){
setOutline: function(val){
this.outline = val
- // show/hide outline
+ if (val && ! this.outlineEl) {
+ this.buildOutline()
+ }
+ this.outlineEl.el.style.display = val ? "block" : "none"
},
setOutlineColor: function(val){
this.outlineColor = val
- // set outline color
+ if (this.outlineEl) {
+ this.outlineColor = this.outlineEl.el.style.borderColor = val
+ }
},
setBillboard: function(val){
this.billboard = val
@@ -65,6 +76,32 @@ Sculpture.types.base = Fiber.extend(function(base){
}
Sculpture.resize.move_dots()
},
+
+ buildOutline: function(){
+ this.outlineEl = new MX.Object3D(".mx-outline")
+ this.outlineEl.width = this.naturalDimensions.a
+ this.outlineEl.height = this.naturalDimensions.c
+ this.outlineEl.scale = this.mx.scale
+ this.outlineEl.rotationX = -PI/2
+ this.outlineEl.x = this.mx.x
+ this.outlineEl.y = sculpture_distance_from_floor
+ this.outlineEl.z = this.mx.z
+ this.outlineEl.el.style.borderColor = this.outlineColor || "#000000"
+ scene.add(this.outlineEl)
+ },
+ updateOutline: function(){
+ if (! this.outline) { return }
+ if (! this.outlineEl) {
+ this.buildOutline()
+ }
+ this.outlineEl.x = this.mx.x
+ this.outlineEl.y = sculpture_distance_from_floor
+ this.outlineEl.z = this.mx.z
+ this.outlineEl.width = this.naturalDimensions.a
+ this.outlineEl.height = this.naturalDimensions.c
+
+ this.outlineEl.scale = this.mx.scale
+ },
remove: function(){
if (this.removed) return
@@ -112,7 +149,7 @@ Sculpture.types.base = Fiber.extend(function(base){
media: this.media,
billboard: this.billboard,
outline: this.outline,
- outlineColor: this.outlineColor,
+ outlineColor: this.outlineColor || "#000000",
backface: this.backface,
}
return data
@@ -123,9 +160,14 @@ Sculpture.types.base = Fiber.extend(function(base){
this.mx.ops.width = data.dimensions.a
this.mx.ops.height = data.dimensions.b
this.billboard = data.billboard
+ this.outline = data.outline
+ this.outlineColor = data.outlineColor || "#000000"
this.backface = data.backface
if (! this.backface) this.mx.el.classList.remove("backface-visible")
this.dimensions.deserialize(data.dimensions)
+ if (this.outline) {
+ this.buildOutline()
+ }
},
}
diff --git a/public/assets/javascripts/rectangles/models/vec3.js b/public/assets/javascripts/rectangles/models/vec3.js
index 97329ed..b3825a9 100644
--- a/public/assets/javascripts/rectangles/models/vec3.js
+++ b/public/assets/javascripts/rectangles/models/vec3.js
@@ -39,5 +39,21 @@ vec3.prototype.serialize = function(){
vec3.prototype.deserialize = function(data){
this.a = data[0]
this.b = data[1]
- this.c = data[2]
+ this.c = data[2] || data[0]
+ return this
+}
+vec3.prototype.clone = function(){
+ return new vec3(this.a, this.b, this.c)
+}
+vec3.prototype.assign = function(v){
+ this.a = v.a
+ this.b = v.b
+ this.c = v.c
+ return this
+}
+vec3.prototype.mul = function(n) {
+ this.a *= n
+ this.b *= n
+ this.c *= n
+ return this
} \ No newline at end of file
diff --git a/public/assets/javascripts/rectangles/util/measurement.js b/public/assets/javascripts/rectangles/util/measurement.js
index d6a0b35..6346eac 100644
--- a/public/assets/javascripts/rectangles/util/measurement.js
+++ b/public/assets/javascripts/rectangles/util/measurement.js
@@ -28,6 +28,10 @@ function measurementToString( n ) {
case 'ft':
ft = floor(n / 36)
inch = abs(round((n % 36) / 3))
+ if (inch == 12) {
+ inch = 0
+ ft += 1
+ }
s = ft + "'"
if (inch > 0) {
s += " " + inch + '"'
diff --git a/public/assets/javascripts/ui/editor/SculptureEditor.js b/public/assets/javascripts/ui/editor/SculptureEditor.js
index 52663e1..953260c 100644
--- a/public/assets/javascripts/ui/editor/SculptureEditor.js
+++ b/public/assets/javascripts/ui/editor/SculptureEditor.js
@@ -17,6 +17,7 @@ var SculptureEditor = FormView.extend({
"change [name=mute]": "setMute",
"change [name=width]": 'changeWidth',
"change [name=height]": 'changeHeight',
+ "change [name=depth]": 'changeDepth',
"change [name=units]": 'changeUnits',
"click [data-role=destroy-sculpture]": "destroy",
},
@@ -35,6 +36,7 @@ var SculptureEditor = FormView.extend({
// image fields
this.$width = this.$("[name=width]")
this.$height = this.$("[name=height]")
+ this.$depth = this.$("[name=depth]")
this.$units = this.$("[name=units]")
// video fields
@@ -168,17 +170,26 @@ var SculptureEditor = FormView.extend({
if (! this.sculpture) return
this.$width.unitVal( Number(this.sculpture.naturalDimensions.a * this.sculpture.scale) || "" )
this.$height.unitVal( Number(this.sculpture.naturalDimensions.b * this.sculpture.scale) || "" )
+ this.$depth.unitVal( Number(this.sculpture.naturalDimensions.c * this.sculpture.scale) || "" )
this.tainted = true
},
changeWidth: function(e){
e.stopPropagation()
this.sculpture.set_scale( this.$width.unitVal() / this.sculpture.naturalDimensions.a )
this.setDimensions()
+ this.sculpture.updateOutline()
},
changeHeight: function(e){
e.stopPropagation()
this.sculpture.set_scale( this.$height.unitVal() / this.sculpture.naturalDimensions.b )
this.setDimensions()
+ this.sculpture.updateOutline()
+ },
+ changeDepth: function(e){
+ e.stopPropagation()
+ this.sculpture.set_depth( this.$depth.unitVal() )
+ this.$depth.unitVal( Number(this.sculpture.naturalDimensions.c * this.sculpture.scale) || "" )
+ this.sculpture.updateOutline()
},
changeUnits: function(){
app.units = this.$units.val()
diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css
index 6e97500..6adb2a0 100755
--- a/public/assets/stylesheets/app.css
+++ b/public/assets/stylesheets/app.css
@@ -1205,6 +1205,13 @@ form .paidPlan label { float: none; font-size: 16px; margin: 0 10px; }
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
+.mx-outline {
+ border-width: 2px;
+ border-style: dashed;
+ -moz-box-sizing: content-box;
+ -webkit-box-sizing: content-box;
+ box-sizing: content-box;
+}
.destroyActive .mx-scene, .destroyActive .mx-object3d.image {
cursor:url(/assets/img/delete-cursor.png), auto;
}
diff --git a/views/controls/editor/sculpture.ejs b/views/controls/editor/sculpture.ejs
index 4b8535a..dfe917f 100644
--- a/views/controls/editor/sculpture.ejs
+++ b/views/controls/editor/sculpture.ejs
@@ -33,7 +33,7 @@
</div>
<div class="setting number">
<label for="sculpture-height">depth</label>
- <input type="text" class="units" name="height" id="sculpture-height">
+ <input type="text" class="units" name="depth" id="sculpture-depth">
</div>
<div class="setting">
<a href="#" class="warn btn" data-role="destroy-sculpture">remove object</a>