Permalink
Browse files

added support for "*" multiply operator

  • Loading branch information...
hartsantler committed Oct 4, 2013
1 parent 71d5664 commit 223b0bb76a76bfc66527259325ea90dc65be4e36
Showing with 54 additions and 0 deletions.
  1. +42 −0 bindings/three.py
  2. +3 −0 pythonscript/python_to_pythonjs.py
  3. +3 −0 pythonscript/pythonjs.py
  4. +6 −0 tests/threejs_vector3.html
View
@@ -64,6 +64,8 @@ def add(self, other):
self.set( self.x+other.x, self.y+other.y, self.z+other.z )
return self
#def __iadd__(self, other):
def addScalar(self, s):
self.set( self.x+s, self.y+s, self.z+s )
return self
@@ -73,6 +75,46 @@ def addVectors(self, a,b):
self.set( a.x+b.x, a.y+b.y, a.z+b.z )
return self
def sub(self, other):
assert isinstance(other, Vector3)
self.set( self.x-other.x, self.y-other.y, self.z-other.z )
return self
def subVectors(self, a,b):
var( a=Vector3, b=Vector3 )
self.set( a.x-b.x, a.y-b.y, a.z-b.z )
return self
def multiply(self, other):
assert isinstance(other, Vector3)
self.set( self.x*other.x, self.y*other.y, self.z*other.z )
return self
def multiplyScalar(self, s):
self.set( self.x*s, self.y*s, self.z*s )
return self
def multiplyVectors(self, a,b):
var( a=Vector3, b=Vector3 )
self.set( a.x*b.x, a.y*b.y, a.z*b.z )
return self
def applyMatrix3(self, m):
vec = self._vec
JS('vec.applyMatrix3(m)')
return self
def applyMatrix4(self, m):
vec = self._vec
JS('vec.applyMatrix4(m)')
return self
def applyProjection(self, m):
vec = self._vec
JS('vec.applyProjection(m)')
return self
class _ObjectBase:
def add(self, child):
@@ -257,6 +257,9 @@ def visit_NotEq(self, node):
def visit_Is(self, node):
return 'is'
def visit_Mult(self, node):
return '*'
def visit_Add(self, node):
return '+'
View
@@ -158,6 +158,9 @@ def visit_BinOp(self, node):
right = self.visit(node.right)
return '%s %s %s' % (left, op, right)
def visit_Mult(self, node):
return '*'
def visit_Add(self, node):
return '+'
@@ -36,6 +36,12 @@
print( v1.y )
print( v1.z )
v1.multiply( v4 )
print( v1.x )
print( v1.y )
print( v1.z )
</script>
</head>

0 comments on commit 223b0bb

Please sign in to comment.