language
stringclasses 1
value | owner
stringlengths 2
15
| repo
stringlengths 2
21
| sha
stringlengths 45
45
| message
stringlengths 7
36.3k
| path
stringlengths 1
199
| patch
stringlengths 15
102k
| is_multipart
bool 2
classes |
---|---|---|---|---|---|---|---|
Other | mrdoob | three.js | 4453bf03df58e32da37c810e56deefeafa6b30ff.json | prepare documentation for programmatic additions | docs/api/textures/Texture.html | @@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <meta charset="utf-8">
+ <meta charset="utf-8" />
<script src="../../list.js"></script>
<script src="../../page.js"></script>
<link type="text/css" rel="stylesheet" href="../../page.css" /> | true |
Other | mrdoob | three.js | fcfac4ba5921a60bbb9d0d19dd9fd7551436d26d.json | update the contributing file for root usage | CONTRIBUTING.md | @@ -1,4 +1,4 @@
-# This board is for bug reports and feature requests only. If you need help, please use [stackoverflow](http://stackoverflow.com/questions/tagged/three.js).
+# The issues section is for bug reports and feature requests only. If you need help, please use [stackoverflow](http://stackoverflow.com/questions/tagged/three.js).
## How to report a bug.
| false |
Other | mrdoob | three.js | b51127000e8cd287b47d79f1af18a846a2e346b6.json | Add Maya ASCII JSON exporter | utils/exporters/maya/README.md | @@ -0,0 +1,24 @@
+# Three.js Maya Export
+
+Exports Maya models to Three.js' ASCII JSON format. Currently supports exporting the following:
+
+- Vertices
+- Faces
+- Normals
+- UV sets
+- Material indices
+- Vertex colors
+
+## Installation
+
+Copy the scripts and plug-ins folders to the appropriate maya folder, where `maya-version` is your current version of Maya (eg. 2013-x64).
+
+- Windows: `C:\Users\username\Documents\maya\maya-version`
+- OSX: `~/Library/Preferences/Autodesk/maya/maya-version`
+- Linux: `/usr/autodesk/userconfig/maya/maya-version`
+
+After that, you need to activate the plugin. In Maya, open `Window > Settings/Preferences > Plug-in Manager` and enable the checkboxes next to `threeJsFileTranslator.py`.
+
+## Usage
+
+Use the regular Export menus within Maya, select `Three.js`.
\ No newline at end of file | true |
Other | mrdoob | three.js | b51127000e8cd287b47d79f1af18a846a2e346b6.json | Add Maya ASCII JSON exporter | utils/exporters/maya/plug-ins/threeJsFileTranlator.py | @@ -0,0 +1,271 @@
+__author__ = 'Chris Lewis'
+__version__ = '0.1.0'
+__email__ = 'clewis1@c.ringling.edu'
+
+import sys
+import json
+
+import maya.cmds as mc
+from maya.OpenMaya import *
+from maya.OpenMayaMPx import *
+
+kPluginTranslatorTypeName = 'Three.js'
+kOptionScript = 'ThreeJsExportScript'
+kDefaultOptionsString = '0'
+
+FLOAT_PRECISION = 8
+
+
+# adds decimal precision to JSON encoding
+class DecimalEncoder(json.JSONEncoder):
+ def _iterencode(self, o, markers=None):
+ if isinstance(o, float):
+ s = str(o)
+ if '.' in s and len(s[s.index('.'):]) > FLOAT_PRECISION - 1:
+ s = '%.{0}f'.format(FLOAT_PRECISION) % o
+ while '.' in s and s[-1] == '0':
+ s = s[-2]
+ return (s for s in [s])
+ return super(DecimalEncoder, self)._iterencode(o, markers)
+
+
+class ThreeJsError(Exception):
+ pass
+
+
+class ThreeJsWriter(object):
+ def __init__(self):
+ self.componentKeys = ['vertices', 'normals', 'colors', 'uvs', 'materials', 'faces']
+
+ def _parseOptions(self, optionsString):
+ self.options = dict([(x, False) for x in self.componentKeys])
+ optionsString = optionsString[2:] # trim off the "0;" that Maya adds to the options string
+ for option in optionsString.split(' '):
+ self.options[option] = True
+
+ def _updateOffsets(self):
+ for key in self.componentKeys:
+ if key == 'uvs':
+ continue
+ self.offsets[key] = len(getattr(self, key))
+ for i in range(len(self.uvs)):
+ self.offsets['uvs'][i] = len(self.uvs[i])
+
+ def _getTypeBitmask(self, options):
+ bitmask = 0
+ if options['materials']:
+ bitmask |= 2
+ if options['uvs']:
+ bitmask |= 8
+ if options['normals']:
+ bitmask |= 32
+ if options['colors']:
+ bitmask |= 128
+ return bitmask
+
+ def _exportMesh(self, dagPath, component):
+ mesh = MFnMesh(dagPath)
+ options = self.options.copy()
+ self._updateOffsets()
+
+ # export vertex data
+ if options['vertices']:
+ try:
+ iterVerts = MItMeshVertex(dagPath, component)
+ while not iterVerts.isDone():
+ point = iterVerts.position(MSpace.kWorld)
+ self.vertices += [point.x, point.y, point.z]
+ iterVerts.next()
+ except:
+ options['vertices'] = False
+
+ # export material data
+ # TODO: actually parse material data
+ materialIndices = MIntArray()
+ if options['materials']:
+ try:
+ shaders = MObjectArray()
+ mesh.getConnectedShaders(0, shaders, materialIndices)
+ while len(self.materials) < shaders.length():
+ self.materials.append({}) # placeholder material definition
+ except:
+ self.materials = [{}]
+
+ # export uv data
+ if options['uvs']:
+ try:
+ uvLayers = []
+ mesh.getUVSetNames(uvLayers)
+ while len(uvLayers) > len(self.uvs):
+ self.uvs.append([])
+ self.offsets['uvs'].append(0)
+ for i, layer in enumerate(uvLayers):
+ uList = MFloatArray()
+ vList = MFloatArray()
+ mesh.getUVs(uList, vList, layer)
+ for j in xrange(uList.length()):
+ self.uvs[i] += [uList[j], vList[j]]
+ except:
+ options['uvs'] = False
+
+ # export normal data
+ if options['normals']:
+ try:
+ normals = MFloatVectorArray()
+ mesh.getNormals(normals, MSpace.kWorld)
+ for i in xrange(normals.length()):
+ point = normals[i]
+ self.normals += [point.x, point.y, point.z]
+ except:
+ options['normals'] = False
+
+ # export color data
+ if options['colors']:
+ try:
+ colors = MColorArray()
+ mesh.getColors(colors)
+ for i in xrange(colors.length()):
+ color = colors[i]
+ # uncolored vertices are set to (-1, -1, -1). Clamps colors to (0, 0, 0).
+ self.colors += [max(color.r, 0), max(color.g, 0), max(color.b, 0)]
+ except:
+ options['colors'] = False
+
+ # export face data
+ if not options['vertices']:
+ return
+ bitmask = self._getTypeBitmask(options)
+ iterPolys = MItMeshPolygon(dagPath, component)
+ while not iterPolys.isDone():
+ self.faces.append(bitmask)
+ # export face vertices
+ verts = MIntArray()
+ iterPolys.getVertices(verts)
+ for i in xrange(verts.length()):
+ self.faces.append(verts[i] + self.offsets['vertices'])
+ # export face vertex materials
+ if options['materials']:
+ if materialIndices.length():
+ self.faces.append(materialIndices[iterPolys.index()])
+ # export face vertex uvs
+ if options['uvs']:
+ util = MScriptUtil()
+ uvPtr = util.asIntPtr()
+ for i, layer in enumerate(uvLayers):
+ for j in xrange(verts.length()):
+ iterPolys.getUVIndex(j, uvPtr, layer)
+ uvIndex = util.getInt(uvPtr)
+ self.faces.append(uvIndex + self.offsets['uvs'][i])
+ # export face vertex normals
+ if options['normals']:
+ for i in xrange(3):
+ normalIndex = iterPolys.normalIndex(i)
+ self.faces.append(normalIndex + self.offsets['normals'])
+ # export face vertex colors
+ if options['colors']:
+ colors = MIntArray()
+ iterPolys.getColorIndices(colors)
+ for i in xrange(colors.length()):
+ self.faces.append(colors[i] + self.offsets['colors'])
+ iterPolys.next()
+
+ def _getMeshes(self, nodes):
+ meshes = []
+ for node in nodes:
+ if mc.nodeType(node) == 'mesh':
+ meshes.append(node)
+ else:
+ for child in mc.listRelatives(node, s=1):
+ if mc.nodeType(child) == 'mesh':
+ meshes.append(child)
+ return meshes
+
+ def _exportMeshes(self):
+ # export all
+ if self.accessMode == MPxFileTranslator.kExportAccessMode:
+ mc.select(self._getMeshes(mc.ls(typ='mesh')))
+ # export selection
+ elif self.accessMode == MPxFileTranslator.kExportActiveAccessMode:
+ mc.select(self._getMeshes(mc.ls(sl=1)))
+ else:
+ raise ThreeJsError('Unsupported access mode: {0}'.format(self.accessMode))
+ dups = [mc.duplicate(mesh)[0] for mesh in mc.ls(sl=1)]
+ combined = mc.polyUnite(dups, mergeUVSets=1, ch=0) if len(dups) > 1 else dups[0]
+ mc.polyTriangulate(combined)
+ mc.select(combined)
+ sel = MSelectionList()
+ MGlobal.getActiveSelectionList(sel)
+ mDag = MDagPath()
+ mComp = MObject()
+ sel.getDagPath(0, mDag, mComp)
+ self._exportMesh(mDag, mComp)
+ mc.delete(combined)
+
+ def write(self, path, optionString, accessMode):
+ self.path = path
+ self._parseOptions(optionString)
+ self.accessMode = accessMode
+ self.root = dict(metadata=dict(formatVersion=3))
+ self.offsets = dict()
+ for key in self.componentKeys:
+ setattr(self, key, [])
+ self.offsets[key] = 0
+ self.offsets['uvs'] = []
+ self.uvs = []
+
+ self._exportMeshes()
+
+ # add the component buffers to the root JSON object
+ for key in self.componentKeys:
+ buffer_ = getattr(self, key)
+ if buffer_:
+ self.root[key] = buffer_
+
+ # materials are required for parsing
+ if not self.root.has_key('materials'):
+ self.root['materials'] = [{}]
+
+ # write the file
+ with file(self.path, 'w') as f:
+ f.write(json.dumps(self.root, separators=(',',':'), cls=DecimalEncoder))
+
+
+class ThreeJsTranslator(MPxFileTranslator):
+ def __init__(self):
+ MPxFileTranslator.__init__(self)
+
+ def haveWriteMethod(self):
+ return True
+
+ def filter(self):
+ return '*.js'
+
+ def defaultExtension(self):
+ return 'js'
+
+ def writer(self, fileObject, optionString, accessMode):
+ path = fileObject.fullName()
+ writer = ThreeJsWriter()
+ writer.write(path, optionString, accessMode)
+
+
+def translatorCreator():
+ return asMPxPtr(ThreeJsTranslator())
+
+
+def initializePlugin(mobject):
+ mplugin = MFnPlugin(mobject)
+ try:
+ mplugin.registerFileTranslator(kPluginTranslatorTypeName, None, translatorCreator, kOptionScript, kDefaultOptionsString)
+ except:
+ sys.stderr.write('Failed to register translator: %s' % kPluginTranslatorTypeName)
+ raise
+
+
+def uninitializePlugin(mobject):
+ mplugin = MFnPlugin(mobject)
+ try:
+ mplugin.deregisterFileTranslator(kPluginTranslatorTypeName)
+ except:
+ sys.stderr.write('Failed to deregister translator: %s' % kPluginTranslatorTypeName)
+ raise
\ No newline at end of file | true |
Other | mrdoob | three.js | b51127000e8cd287b47d79f1af18a846a2e346b6.json | Add Maya ASCII JSON exporter | utils/exporters/maya/scripts/ThreeJsExportScript.mel | @@ -0,0 +1,37 @@
+// ThreeJsExportScript.mel
+// Author: Chris Lewis
+// Email: clewis1@c.ringling.edu
+
+global proc int ThreeJsExportScript(string $parent, string $action, string $settings, string $callback)
+{
+ if ($action == "post")
+ {
+ setParent $parent;
+ columnLayout -adj true;
+ checkBox -v true -l "Vertices" vertsCb;
+ checkBox -v true -l "Faces" facesCb;
+ checkBox -v true -l "Normals" normalsCb;
+ checkBox -v true -l "UVs" uvsCb;
+ checkBox -v false -l "Material Indices" materialsCb;
+ checkBox -v false -l "Colors" colorsCb;
+ }
+ else if ($action == "query")
+ {
+ string $option = "\"";
+ if (`checkBox -q -v vertsCb`)
+ $option += "vertices ";
+ if (`checkBox -q -v facesCb`)
+ $option += "faces ";
+ if (`checkBox -q -v normalsCb`)
+ $option += "normals ";
+ if (`checkBox -q -v uvsCb`)
+ $option += "uvs ";
+ if (`checkBox -q -v materialsCb`)
+ $option += "materials ";
+ if (`checkBox -q -v colorsCb`)
+ $option += "colors ";
+ $option += "\"";
+ eval($callback + $option);
+ }
+ return 1;
+}
\ No newline at end of file | true |
Other | mrdoob | three.js | ed00cd63fac6a13c55ccdd40c7c55d6931c118de.json | make autoResize optional. Fixes #2969 | src/renderers/WebGLRenderer.js | @@ -293,15 +293,24 @@ THREE.WebGLRenderer = function ( parameters ) {
};
- this.setSize = function ( width, height ) {
+ this.setSize = function ( width, height, autoResize ) {
+
+ if ( autoResize === undefined ) {
+ autoResize = true;
+ }
_canvas.width = width * this.devicePixelRatio;
_canvas.height = height * this.devicePixelRatio;
-
- _canvas.style.width = width + 'px';
- _canvas.style.height = height + 'px';
+
+ if ( autoResize ){
+
+ _canvas.style.width = width + 'px';
+ _canvas.style.height = height + 'px';
+
+ }
this.setViewport( 0, 0, _canvas.width, _canvas.height );
+
};
| false |
Other | mrdoob | three.js | 4c35f20a438b255a42fa7581f60d6bb1e47c359b.json | add light documentation | docs/api/lights/Light.html | @@ -17,12 +17,20 @@ <h1>[name]</h1>
<h2>Constructor</h2>
<h3>[name]( [page:Integer hex] )</h3>
+ <div>
+ [page:Integer hex] β Numeric value of the RGB component of the color.
+ </div>
+ <div>
+ This creates a light with color.<br />
+ </div>
<h2>Properties</h2>
<h3>.[page:Color color]</h3>
-
+ <div>
+ Color of the light.<br />
+ </div>
<h2>Source</h2>
| false |
Other | mrdoob | three.js | 6f30f4863b22065060515aeaf3caba843f7de233.json | update Raycaster documentation | docs/api/core/Raycaster.html | @@ -9,24 +9,77 @@
<body>
<h1>[name]</h1>
- <div class="desc">todo</div>
+ <div class="desc">
+ This class makes raycasting easier. Raycasting is used for picking and more.
+
+ </div>
<h2>Constructor</h2>
- <h3>[name]()</h3>
+ <h3>[name]( [page:Vector3 origin], [page:Vector3 direction], [page:Float near], [page:Float far] ) {</h3>
+ <div>
+ [page:Vector3 origin] β The origin vector where the ray casts from.<br />
+ [page:Vector3 direction] β The direction vector that gives direction to the ray.<br />
+ [page:Float near] β All results returned are further away then near. Near can't be negative. Default value is 0.<br />
+ [page:Float far] β All results returned are closer then far. Far can't be lower then near . Default value is Infinity.
+ </div>
+ <div>
+ This creates a new raycaster object.<br />
+ </div>
<h2>Properties</h2>
- <h3>.[page:Vector3 todo]</h3>
+ <h3>.[page:Ray ray]</h3>
+ <div>
+ The Ray used for the raycasting.
+ </div>
+
+ <h3>.[page:float near]</h3>
+ <div>
+ The near factor of the raycaster. This value indicates which objects can be discarded based on the distance.<br />
+ This value shouldn't be negative and should be smaller then the far property.
+ </div>
+ <h3>.[page:float far]</h3>
+ <div>
+ The far factor of the raycaster. This value indicates which objects can be discarded based on the distance.<br />
+ This value shouldn't be negative and should be smaller then the far property.
+ </div>
+
+ <h3>.[page:float precision]</h3>
+ <div>
+ The precision factor of the raycaster.
+ </div>
<h2>Methods</h2>
- <h3>.todo( [page:Vector3 todo] )</h3>
+ <h3>.set( [page:Vector3 origin], [page:Vector3 direction] )</h3>
+ <div>
+ [page:Vector3 origin] β The origin vector where the ray casts from.<br />
+ [page:Vector3 direction] β The direction vector that gives direction to the ray.
+ </div>
+ <div>
+ Updates the ray with a new origin and direction.
+ </div>
+
+ <h3>.intersectObject( [page:Object3D object], [page:Boolean recursive] )</h3>
+ <div>
+ [page:Object3D object] β The object to check for intersection with the ray.<br />
+ [page:Boolean recursive] β If set, it also checks all descendants. Otherwise it only checks intersecton with the object.
+ </div>
+ <div>
+ checks all intersection between the ray and the object with or without the descendants.
+ </div>
+
+ <h3>.intersectObjects( [page:Array objects], [page:Boolean recursive] )</h3>
+ <div>
+ [page:Array objects] β The objects to check for intersection with the ray.<br />
+ [page:Boolean recursive] β If set, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects.
+ </div>
<div>
- todo β todo<br />
+ checks all intersection between the ray and the objects with or without the descendants.
</div>
| false |
Other | mrdoob | three.js | 4691b5f1b0460bfc5c0e26c28e8f7a8fa9acca05.json | Use process.hrtime() for Clock in node.js builds
As discussed in #2975. | utils/npm/header.js | @@ -1,3 +1,21 @@
var window = window || {};
var self = self || {};
+
+// High-resulution counter: emulate window.performance.now() for THREE.CLOCK
+if( window.performance === undefined ) {
+
+ window.performance = { };
+
+}
+
+if( window.performance.now === undefined ) {
+
+ window.performance.now = function () {
+
+ var time = process.hrtime();
+ return ( time[0] + time[1] / 1e9 ) * 1000;
+
+ };
+
+} | false |
Other | mrdoob | three.js | e88ca555cb1c5397288cb78e2680116a30cc754b.json | update geometry documentation | docs/api/core/Geometry.html | @@ -9,7 +9,10 @@
<body>
<h1>[name]</h1>
- <div class="desc">Base class for geometries</div>
+ <div class="desc">
+ Base class for geometries.<br />
+ A geometry holds all data nessecary to describe a 3D model.
+ </div>
<h2>Example</h2>
@@ -44,42 +47,51 @@ <h3>.[page:String name]</h3>
<h3>.[page:Array vertices]</h3>
<div>
- Array of [page:Vector3 vertices].
+ Array of [page:Vector3 vertices].<br />
+ The array of vertices hold every position of points of the model.<br />
+ To signal an update in this array, [page:Geometry Geometry.verticesNeedUpdate] needs to be set to true.
</div>
<h3>.[page:Array colors]</h3>
<div>
Array of vertex [page:Color colors], matching number and order of vertices.<br />
Used in [page:ParticleSystem], [page:Line] and [page:Ribbon].<br />
- [page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.
+ [page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.<br />
+ To signal an update in this array, [page:Geometry Geometry.colorsNeedUpdate] needs to be set to true.
</div>
- <h3>.[page:Array materials]</h3>
+ <h3>.[page:Array normals]</h3>
<div>
- Array of [page:Material materials].
+ Array of vertex [page:Vector3 normals], matching number and order of vertices.<br />
+ [link:http://en.wikipedia.org/wiki/Normal_(geometry) Normal vectors] are nessecary for lighting <br />
+ To signal an update in this array, [page:Geometry Geometry.normalsNeedUpdate] needs to be set to true.
</div>
<h3>.[page:Array faces]</h3>
<div>
- Array of [page:Face3 triangles] or/and [page:Face4 quads].
+ Array of [page:Face3 triangles] or/and [page:Face4 quads].<br />
+ The array of faces describe how each vertex in the model is connected with each other.<br />
+ To signal an update in this array, [page:Geometry Geometry.elementsNeedUpdate] needs to be set to true.
</div>
<h3>.[page:Array faceUvs]</h3>
<div>
Array of face [page:UV] layers.<br />
- Each UV layer is an array of [page:UV] matching order and number of faces.
+ Each UV layer is an array of [page:UV] matching order and number of faces.<br />
+ To signal an update in this array, [page:Geometry Geometry.uvsNeedUpdate] needs to be set to true.
</div>
<h3>.[page:Array faceVertexUvs]</h3>
<div>
Array of face [page:UV] layers.<br />
- Each UV layer is an array of [page:UV] matching order and number of vertices in faces.
+ Each UV layer is an array of [page:UV] matching order and number of vertices in faces.<br />
+ To signal an update in this array, [page:Geometry Geometry.uvsNeedUpdate] needs to be set to true.
</div>
<h3>.[page:Array morphTargets]</h3>
<div>
Array of morph targets. Each morph target is a Javascript object:
- <code>{ name: "targetName", vertices: [ new THREE.Vertex(), ... ] }</code>
+ <code>{ name: "targetName", vertices: [ new THREE.Vector3(), ... ] }</code>
Morph vertices match number and order of primary vertices.
</div>
@@ -90,6 +102,12 @@ <h3>.[page:Array morphColors]</h3>
Morph colors can match either number and order of faces (face colors) or number of vertices (vertex colors).
</div>
+ <h3>.[page:Array morphColors]</h3>
+ <div>
+ Array of morph normals. Morph Normals have similar structure as morph targets, each normal set is a Javascript object:
+ <code>morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] }</code>
+ </div>
+
<h3>.[page:Array skinWeights]</h3>
<div>
Array of skinning weights, matching number and order of vertices.
@@ -120,9 +138,49 @@ <h3>.[page:Boolean hasTangents]</h3>
<h3>.[page:Boolean dynamic]</h3>
<div>
Set to *true* if attribute buffers will need to change in runtime (using "dirty" flags).<br/>
- Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.
+ Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.<br/>
+ Defaults to true.
+ </div>
+
+ <h3>.verticesNeedUpdate</h3>
+ <div>
+ Set to *true* if the vertices array has been updated.
+ </div>
+
+ <h3>.elementsNeedUpdate</h3>
+ <div>
+ Set to *true* if the faces array has been updated.
+ </div>
+
+ <h3>.uvsNeedUpdate</h3>
+ <div>
+ Set to *true* if the uvs array has been updated.
+ </div>
+
+ <h3>.normalsNeedUpdate</h3>
+ <div>
+ Set to *true* if the normals array has been updated.
+ </div>
+
+ <h3>.tangentsNeedUpdate</h3>
+ <div>
+ Set to *true* if the tangents in the faces has been updated.
+ </div>
+
+ <h3>.colorsNeedUpdate</h3>
+ <div>
+ Set to *true* if the colors array has been updated.
+ </div>
+
+ <h3>.lineDistancesNeedUpdate</h3>
+ <div>
+ Set to *true* if the linedistances array has been updated.
+ </div>
+
+ <h3>.buffersNeedUpdate</h3>
+ <div>
+ Set to *true* if an array has changed in length.
</div>
-
<h2>Methods</h2>
@@ -147,6 +205,11 @@ <h3>.computeVertexNormals()</h3>
Face normals must be existing / computed beforehand.
</div>
+ <h3>.computeMorphNormals()</h3>
+ <div>
+ Computes morph normals.
+ </div>
+
<h3>.computeTangents()</h3>
<div>
Computes vertex tangents.<br />
@@ -171,6 +234,17 @@ <h3>.mergeVertices()</h3>
Checks for duplicate vertices using hashmap.<br />
Duplicated vertices are removed and faces' vertices are updated.
</div>
+
+ <h3>.clone()</h3>
+ <div>
+ Creates a new clone of the Geometry.
+ </div>
+
+ <h3>.dispose()</h3>
+ <div>
+ Removes The object from memory. <br />
+ Don't forget to call this method when you remove an geometry because it can cuase meomory leaks.
+ </div>
<h2>Source</h2> | false |
Other | mrdoob | three.js | 33c6134f6a5223e839296553ead9a7bf73713ef7.json | update clone Method to Face4 documentation | docs/api/core/Face4.html | @@ -92,7 +92,14 @@ <h3>.[page:Vector3 centroid]</h3>
Face centroid.
</div>
+ <h2>Methods</h2>
+ <h3>.clone()</h3>
+ <div>
+ Creates a new clone of the Face4 object.
+ </div>
+
+
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] | false |
Other | mrdoob | three.js | 2202a5feb80627cd2b729bb9d64d8da01277221b.json | update clone Method to Face3 documentation | docs/api/core/Face3.html | @@ -86,7 +86,14 @@ <h3>.[page:Vector3 centroid]</h3>
Face centroid.
</div>
+ <h2>Methods</h2>
+ <h3>.clone()</h3>
+ <div>
+ Creates a new clone of the Face3 object.
+ </div>
+
+
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] | false |
Other | mrdoob | three.js | 68fe0d9d8aba356ce641d099bfeee15c8167ebe8.json | update documentation for evendispatcher | docs/api/core/EventDispatcher.html | @@ -24,7 +24,9 @@ <h2>Example</h2>
};
var car = new Car();
-car.addEventListener( 'start', function ( event ) { alert( event.message ); } );
+car.addEventListener( 'start', function ( event ) {
+ alert( event.message );
+} );
car.start();
</code>
@@ -38,7 +40,7 @@ <h3>[name]()</h3>
<h2>Methods</h2>
- <h3>.addEventListener( [page:String type], [page:Function listener] </h3>
+ <h3>.addEventListener( [page:String type], [page:Function listener] )</h3>
<div>
type - The type of event to listen to.<br />
listener - The function that gets called when the event is fired.
@@ -47,7 +49,7 @@ <h3>.addEventListener( [page:String type], [page:Function listener] </h3>
Adds a listener to an event type.
</div>
- <h3>.removeEventListener( [page:String type], [page:Function listener] </h3>
+ <h3>.removeEventListener( [page:String type], [page:Function listener] )</h3>
<div>
type - The type of the listener that gets removed.<br />
listener - The listener function that gets removed.
@@ -56,7 +58,7 @@ <h3>.removeEventListener( [page:String type], [page:Function listener] </h3>
Removes a listener from an event type.
</div>
- <h3>.dispatchEvent( [page:String type]</h3>
+ <h3>.dispatchEvent( [page:String type] )</h3>
<div>
type - The type of event that gets fired.
</div> | false |
Other | mrdoob | three.js | e8c50b6794a3f61cb930b762b48346ecd836b2fd.json | add documentation for evendispatcher | docs/api/core/EventDispatcher.html | @@ -9,24 +9,59 @@
<body>
<h1>[name]</h1>
- <div class="desc">todo</div>
+ <div class="desc">JavaScript events for custom objects</div>
+
+ <h2>Example</h2>
+ <code>
+var Car = function () {
+
+ EventDispatcher.call( this );
+ this.start = function () {
+ this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
+ };
+
+};
+
+var car = new Car();
+car.addEventListener( 'start', function ( event ) { alert( event.message ); } );
+car.start();
+ </code>
<h2>Constructor</h2>
<h3>[name]()</h3>
+ <div>
+ Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object.
+ </div>
- <h2>Properties</h2>
-
- <h3>.[page:Vector3 todo]</h3>
+ <h2>Methods</h2>
+ <h3>.addEventListener( [page:String type], [page:Function listener] </h3>
+ <div>
+ type - The type of event to listen to.<br />
+ listener - The function that gets called when the event is fired.
+ </div>
+ <div>
+ Adds a listener to an event type.
+ </div>
- <h2>Methods</h2>
+ <h3>.removeEventListener( [page:String type], [page:Function listener] </h3>
+ <div>
+ type - The type of the listener that gets removed.<br />
+ listener - The listener function that gets removed.
+ </div>
+ <div>
+ Removes a listener from an event type.
+ </div>
- <h3>.todo( [page:Vector3 todo] )</h3>
+ <h3>.dispatchEvent( [page:String type]</h3>
+ <div>
+ type - The type of event that gets fired.
+ </div>
<div>
- todo β todo<br />
+ Fire an event type.
</div>
| false |
Other | mrdoob | three.js | f1dd1daf22c8640de503b70fe5be0594200e9422.json | add myself as author | src/renderers/WebGLRenderer2.js | @@ -3,6 +3,7 @@
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
* @author szimek / https://github.com/szimek/
+ * @author gero3 / https://github.com/gero3/
*/
THREE.WebGLRenderer2 = function ( parameters ) {
@@ -3294,4 +3295,4 @@ THREE.WebGLRenderer2 = function ( parameters ) {
};
-THREE.WebGLRenderer = THREE.WebGLRenderer2;
+//THREE.WebGLRenderer = THREE.WebGLRenderer2; | false |
Other | mrdoob | three.js | dcd25863e4d083c1945fab6380bdf06543d7397e.json | Add isIntersectionSphere to sphere
Tets if two spheres intersect | src/math/Sphere.js | @@ -67,6 +67,12 @@ THREE.Sphere.prototype = {
},
+ isIntersectionSphere: function(sphere) {
+
+ return ( sphere.center.distanceToSquared( this.center ) <= ( this.radius * this.radius + sphere.radius * sphere.radius) );
+
+ },
+
clampPoint: function ( point, optionalTarget ) {
var deltaLengthSq = this.center.distanceToSquared( point ); | false |
Other | mrdoob | three.js | 5d6656506bdd25d01ab0e5b60591ff2a839b4db5.json | remove unused variable from Frustum.js | src/math/Frustum.js | @@ -189,6 +189,4 @@ THREE.Frustum.prototype = {
}
-};
-
-THREE.Frustum.__s0 = new THREE.Sphere();
\ No newline at end of file
+};
\ No newline at end of file | false |
Other | mrdoob | three.js | b358c94547ea3948841f433ee0a84879366ee56e.json | expand Frustum.contains() per @alteredq, @gero3 | src/math/Frustum.js | @@ -72,10 +72,25 @@ THREE.Frustum.prototype = {
contains: function ( object ) {
- var sphere = THREE.Frustum.__s0.copy( object.geometry.boundingSphere );
- sphere.transform( object.matrixWorld );
+ // this method is expanded inlined for performance reasons.
+ var matrix = object.matrixWorld;
+ var planes = this.planes;
+ var center = matrix.getPosition();
+ var negRadius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
+
+ for ( var i = 0; i < 6; i ++ ) {
+
+ var distance = planes[ i ].distanceToPoint( center );
+
+ if( distance < negRadius ) {
- return this.containsSphere( sphere );
+ return false;
+
+ }
+
+ }
+
+ return true;
},
| false |
Other | mrdoob | three.js | ddd0803d8ace4fb43e1950e7b60f26a7625b6631.json | Fix serialization error in Maya exporter | utils/exporters/maya/plug-ins/threeJsFileTranslator.py | @@ -24,7 +24,9 @@ def _iterencode(self, o, markers=None):
if '.' in s and len(s[s.index('.'):]) > FLOAT_PRECISION - 1:
s = '%.{0}f'.format(FLOAT_PRECISION) % o
while '.' in s and s[-1] == '0':
- s = s[-2]
+ s = s[:-1] # this actually removes the last "0" from the string
+ if s[-1] == '.': # added this test to avoid leaving "0." instead of "0.0",
+ s += '0' # which would throw an error while loading the file
return (s for s in [s])
return super(DecimalEncoder, self)._iterencode(o, markers)
| false |
Other | mrdoob | three.js | bd7fda284d34cbb76ef120beed21ab55815e2089.json | add an improved version of the STLLoader | examples/js/loaders/STLLoader.js | @@ -8,7 +8,7 @@
* Supports both binary and ASCII encoded files, with automatic detection of type.
*
* Limitations: Binary decoding ignores header. There doesn't seem to be much of a use for it.
- * There is perhaps some question as to how valid it is to always assume little-endian-ness.
+ * There is perhaps some question as to how valid it is to always assume little-endian-ness.
* ASCII decoding assumes file is UTF-8. Seems to work for the examples...
*
* Usage:
@@ -46,7 +46,7 @@ THREE.STLLoader.prototype.load = function (url, callback) {
if ( event.target.status === 200 || event.target.status === 0 ) {
- var geometry = scope.parse( event.target.responseText );
+ var geometry = scope.parse( event.target.response || event.target.responseText );
scope.dispatchEvent( { type: 'load', content: geometry } );
@@ -77,64 +77,68 @@ THREE.STLLoader.prototype.load = function (url, callback) {
xhr.overrideMimeType('text/plain; charset=x-user-defined');
xhr.open( 'GET', url, true );
+ xhr.responseType = "arraybuffer";
xhr.send( null );
};
THREE.STLLoader.prototype.parse = function (data) {
- var isBinary = function (data) {
+
+ var isBinary = function () {
var expect, face_size, n_faces, reader;
- reader = new THREE.STLLoader.BinaryReader(data);
- reader.seek(80);
+ reader = new DataView( binData );
face_size = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
- n_faces = reader.readUInt32();
+ n_faces = reader.getUint32(80,true);
expect = 80 + (32 / 8) + (n_faces * face_size);
- return expect === reader.getSize();
+ return expect === reader.byteLength;
};
+
+ var binData = this.ensureBinary(data);
- if (isBinary(data)) {
+ if (isBinary()) {
- return this.parseBinary(data);
+ return this.parseBinary(binData);
} else {
-
- return this.parseASCII(data);
+
+ return this.parseASCII(this.ensureString(data));
}
};
THREE.STLLoader.prototype.parseBinary = function (data) {
- var face, geometry, n_faces, reader, length, normal, i;
-
- reader = new THREE.STLLoader.BinaryReader(data);
- reader.seek(80);
- n_faces = reader.readUInt32();
+ var face, geometry, n_faces, reader, length, normal, i, dataOffset, faceLength, start, vertexstart;
+
+ reader = new DataView( data );
+ n_faces = reader.getUint32(80,true);
geometry = new THREE.Geometry();
-
+ dataOffset = 84;
+ faceLength = 12 * 4 + 2;
+
for (face = 0; face < n_faces; face++) {
- normal = new THREE.Vector3(reader.readFloat(),reader.readFloat(),reader.readFloat());
+ start = dataOffset + face * faceLength;
+ normal = new THREE.Vector3(reader.getFloat32(start,true),reader.getFloat32(start + 4,true),reader.getFloat32(start + 8,true));
for (i = 1; i <= 3; i++) {
-
- geometry.vertices.push(new THREE.Vector3(reader.readFloat(),reader.readFloat(),reader.readFloat()));
+
+ vertexstart = start + i * 12;
+ geometry.vertices.push(new THREE.Vector3(reader.getFloat32(vertexstart,true),reader.getFloat32(vertexstart +4,true),reader.getFloat32(vertexstart + 8,true)));
}
- reader.readUInt16(); // attr doesn't get used yet.
length = geometry.vertices.length;
geometry.faces.push(new THREE.Face3(length - 3, length - 2, length - 1, normal));
}
geometry.computeCentroids();
- geometry.computeBoundingBox();
geometry.computeBoundingSphere();
-
+
return geometry;
};
@@ -177,153 +181,173 @@ THREE.STLLoader.prototype.parseASCII = function (data) {
};
-
-THREE.STLLoader.BinaryReader = function (data) {
-
- this._buffer = data;
- this._pos = 0;
+THREE.STLLoader.prototype.ensureString = function (buf) {
+
+ if (typeof buf !== "string"){
+ var array_buffer = new Uint8Array(buf);
+ var str = '';
+ for(var i = 0; i < buf.byteLength; i++) {
+ str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+ }
+ return str;
+ } else {
+ return buf;
+ }
};
+THREE.STLLoader.prototype.ensureBinary = function (buf) {
+
+ if (typeof buf === "string"){
+ var array_buffer = new Uint8Array(buf.length);
+ for(var i = 0; i < buf.length; i++) {
+ array_buffer[i] = buf.charCodeAt(i) & 0xff; // implicitly assumes little-endian
+ }
+ return array_buffer.buffer || array_buffer;
+ } else {
+ return buf;
+ }
-THREE.STLLoader.BinaryReader.prototype = {
-
- /* Public */
-
- readInt8: function (){ return this._decodeInt(8, true); },
- readUInt8: function (){ return this._decodeInt(8, false); },
- readInt16: function (){ return this._decodeInt(16, true); },
- readUInt16: function (){ return this._decodeInt(16, false); },
- readInt32: function (){ return this._decodeInt(32, true); },
- readUInt32: function (){ return this._decodeInt(32, false); },
-
- readFloat: function (){ return this._decodeFloat(23, 8); },
- readDouble: function (){ return this._decodeFloat(52, 11); },
-
- readChar: function () { return this.readString(1); },
-
- readString: function (length) {
-
- this._checkSize(length * 8);
- var result = this._buffer.substr(this._pos, length);
- this._pos += length;
- return result;
-
- },
-
- seek: function (pos) {
-
- this._pos = pos;
- this._checkSize(0);
-
- },
-
- getPosition: function () {
-
- return this._pos;
-
- },
-
- getSize: function () {
-
- return this._buffer.length;
-
- },
-
-
- /* Private */
-
- _decodeFloat: function(precisionBits, exponentBits){
-
- var length = precisionBits + exponentBits + 1;
- var size = length >> 3;
-
- this._checkSize(length);
+};
- var bias = Math.pow(2, exponentBits - 1) - 1;
- var signal = this._readBits(precisionBits + exponentBits, 1, size);
- var exponent = this._readBits(precisionBits, exponentBits, size);
- var significand = 0;
- var divisor = 2;
- // var curByte = length + (-precisionBits >> 3) - 1;
- var curByte = 0;
- do {
- var byteValue = this._readByte(++curByte, size);
- var startBit = precisionBits % 8 || 8;
- var mask = 1 << startBit;
- while (mask >>= 1) {
- if (byteValue & mask) {
- significand += 1 / divisor;
+if ( typeof DataView === 'undefined'){
+
+ DataView = function(buffer, byteOffset, byteLength){
+ this.buffer = buffer;
+ this.byteOffset = byteOffset || 0;
+ this.byteLength = byteLength || buffer.byteLength || buffer.length;
+ this._isString = typeof buffer === "string";
+
+ }
+
+ DataView.prototype = {
+ _getCharCodes:function(buffer,start,length){
+ start = start || 0;
+ length = length || buffer.length;
+ var end = start + length;
+ var codes = [];
+ for (var i = start; i < end; i++) {
+ codes.push(buffer.charCodeAt(i) & 0xff);
+ }
+ return codes;
+ },
+
+ _getBytes: function (length, byteOffset, littleEndian) {
+ var result;
+
+ // Handle the lack of endianness
+ if (littleEndian === undefined) {
+ littleEndian = this._littleEndian;
+ }
+
+ // Handle the lack of byteOffset
+ if (byteOffset === undefined) {
+ byteOffset = this.byteOffset;
+ } else {
+ byteOffset = this.byteOffset + byteOffset;
+ }
+
+ if (length === undefined) {
+ length = this.byteLength - byteOffset;
+ }
+
+ // Error Checking
+ if (typeof byteOffset !== 'number') {
+ throw new TypeError('DataView byteOffset is not a number');
+ }
+ if (length < 0 || byteOffset + length > this.byteLength) {
+ throw new Error('DataView length or (byteOffset+length) value is out of bounds');
+ }
+
+ if (this.isString){
+ result = this._getCharCodes(this.buffer, byteOffset, byteOffset + length);
+ } else {
+ result = this.buffer.slice(byteOffset, byteOffset + length);
+ }
+
+ if (!littleEndian && length > 1) {
+ if (!(result instanceof Array)) {
+ result = Array.prototype.slice.call(result);
}
- divisor *= 2;
+
+ result.reverse();
}
- } while (precisionBits -= startBit);
-
- this._pos += size;
-
- return exponent == (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity
- : (1 + signal * -2) * (exponent || significand ? !exponent ? Math.pow(2, -bias + 1) * significand
- : Math.pow(2, exponent - bias) * (1 + significand) : 0);
-
- },
-
- _decodeInt: function(bits, signed){
-
- var x = this._readBits(0, bits, bits / 8), max = Math.pow(2, bits);
- var result = signed && x >= max / 2 ? x - max : x;
-
- this._pos += bits / 8;
- return result;
-
- },
-
- //shl fix: Henri Torgemane ~1996 (compressed by Jonas Raoni)
- _shl: function (a, b){
-
- for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1);
- return a;
-
- },
-
- _readByte: function (i, size) {
-
- return this._buffer.charCodeAt(this._pos + size - i - 1) & 0xff;
-
- },
-
- _readBits: function (start, length, size) {
-
- var offsetLeft = (start + length) % 8;
- var offsetRight = start % 8;
- var curByte = size - (start >> 3) - 1;
- var lastByte = size + (-(start + length) >> 3);
- var diff = curByte - lastByte;
-
- var sum = (this._readByte(curByte, size) >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1);
-
- if (diff && offsetLeft) {
-
- sum += (this._readByte(lastByte++, size) & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight;
-
- }
-
- while (diff) {
-
- sum += this._shl(this._readByte(lastByte++, size), (diff-- << 3) - offsetRight);
-
- }
-
- return sum;
-
- },
-
- _checkSize: function (neededBits) {
-
- if (!(this._pos + Math.ceil(neededBits / 8) < this._buffer.length)) {
-
- throw new Error("Index out of bound");
-
+
+ return result;
+ },
+
+ // Compatibility functions on a String Buffer
+
+ getFloat64: function (byteOffset, littleEndian) {
+ var b = this._getBytes(8, byteOffset, littleEndian),
+
+ sign = 1 - (2 * (b[7] >> 7)),
+ exponent = ((((b[7] << 1) & 0xff) << 3) | (b[6] >> 4)) - ((1 << 10) - 1),
+
+ // Binary operators such as | and << operate on 32 bit values, using + and Math.pow(2) instead
+ mantissa = ((b[6] & 0x0f) * Math.pow(2, 48)) + (b[5] * Math.pow(2, 40)) + (b[4] * Math.pow(2, 32)) +
+ (b[3] * Math.pow(2, 24)) + (b[2] * Math.pow(2, 16)) + (b[1] * Math.pow(2, 8)) + b[0];
+
+ if (exponent === 1024) {
+ if (mantissa !== 0) {
+ return NaN;
+ } else {
+ return sign * Infinity;
+ }
+ }
+
+ if (exponent === -1023) { // Denormalized
+ return sign * mantissa * Math.pow(2, -1022 - 52);
+ }
+
+ return sign * (1 + mantissa * Math.pow(2, -52)) * Math.pow(2, exponent);
+ },
+
+ getFloat32: function (byteOffset, littleEndian) {
+ var b = this._getBytes(4, byteOffset, littleEndian),
+
+ sign = 1 - (2 * (b[3] >> 7)),
+ exponent = (((b[3] << 1) & 0xff) | (b[2] >> 7)) - 127,
+ mantissa = ((b[2] & 0x7f) << 16) | (b[1] << 8) | b[0];
+
+ if (exponent === 128) {
+ if (mantissa !== 0) {
+ return NaN;
+ } else {
+ return sign * Infinity;
+ }
+ }
+
+ if (exponent === -127) { // Denormalized
+ return sign * mantissa * Math.pow(2, -126 - 23);
+ }
+
+ return sign * (1 + mantissa * Math.pow(2, -23)) * Math.pow(2, exponent);
+ },
+
+ getInt32: function (byteOffset, littleEndian) {
+ var b = this._getBytes(4, byteOffset, littleEndian);
+ return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];
+ },
+
+ getUint32: function (byteOffset, littleEndian) {
+ return this.getInt32(byteOffset, littleEndian) >>> 0;
+ },
+
+ getInt16: function (byteOffset, littleEndian) {
+ return (this.getUint16(byteOffset, littleEndian) << 16) >> 16;
+ },
+
+ getUint16: function (byteOffset, littleEndian) {
+ var b = this._getBytes(2, byteOffset, littleEndian);
+ return (b[1] << 8) | b[0];
+ },
+
+ getInt8: function (byteOffset) {
+ return (this.getUint8(byteOffset) << 24) >> 24;
+ },
+
+ getUint8: function (byteOffset) {
+ return this._getBytes(1, byteOffset)[0];
}
-
- }
-
-};
+ };
+} | false |
Other | mrdoob | three.js | 3c5986bf7996a00c91378337c6b528012e4955dd.json | incorporate Line3 into Plane. | src/math/Plane.js | @@ -115,12 +115,12 @@ THREE.extend( THREE.Plane.prototype, {
},
- isIntersectionLine: function ( startPoint, endPoint ) {
+ isIntersectionLine: function ( line ) {
// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
- var startSign = this.distanceToPoint( startPoint );
- var endSign = this.distanceToPoint( endPoint );
+ var startSign = this.distanceToPoint( line.start );
+ var endSign = this.distanceToPoint( line.end );
return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );
@@ -130,20 +130,20 @@ THREE.extend( THREE.Plane.prototype, {
var v1 = new THREE.Vector3();
- return function ( startPoint, endPoint, optionalTarget ) {
+ return function ( line, optionalTarget ) {
var result = optionalTarget || new THREE.Vector3();
- var direction = v1.subVectors( endPoint, startPoint );
+ var direction = line.delta( v1 );
var denominator = this.normal.dot( direction );
if ( denominator == 0 ) {
// line is coplanar, return origin
- if( this.distanceToPoint( startPoint ) == 0 ) {
+ if( this.distanceToPoint( line.start ) == 0 ) {
- return result.copy( startPoint );
+ return result.copy( line.start );
}
@@ -152,15 +152,15 @@ THREE.extend( THREE.Plane.prototype, {
}
- var t = - ( startPoint.dot( this.normal ) + this.constant ) / denominator;
+ var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
if( t < 0 || t > 1 ) {
return undefined;
}
- return result.copy( direction ).multiplyScalar( t ).add( startPoint );
+ return result.copy( direction ).multiplyScalar( t ).add( line.start );
};
| true |
Other | mrdoob | three.js | 3c5986bf7996a00c91378337c6b528012e4955dd.json | incorporate Line3 into Plane. | test/unit/math/Plane.js | @@ -131,24 +131,25 @@ test( "distanceToSphere", function() {
test( "isInterestionLine/intersectLine", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
- ok( a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
- ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
+ var l1 = new THREE.Line3( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) );
+ ok( a.isIntersectionLine( l1 ), "Passed!" );
+ ok( a.intersectLine( l1 ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -3 );
- ok( a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
- ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ).equals( new THREE.Vector3( 3, 0, 0 ) ), "Passed!" );
+ ok( a.isIntersectionLine( l1 ), "Passed!" );
+ ok( a.intersectLine( l1 ).equals( new THREE.Vector3( 3, 0, 0 ) ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -11 );
- ok( ! a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
- ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ) === undefined, "Passed!" );
+ ok( ! a.isIntersectionLine( l1 ), "Passed!" );
+ ok( a.intersectLine( l1 ) === undefined, "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 11 );
- ok( ! a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
- ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ) === undefined, "Passed!" );
+ ok( ! a.isIntersectionLine( l1 ), "Passed!" );
+ ok( a.intersectLine( l1 ) === undefined, "Passed!" );
});
| true |
Other | mrdoob | three.js | e08369e8151e50b2aae861c86a2bfdcf8073e8e9.json | fix bug in Line3.distance/distanceSq | src/math/Line3.js | @@ -43,13 +43,13 @@ THREE.extend( THREE.Line3.prototype, {
},
- distanceSq: function ( optionalTarget ) {
+ distanceSq: function () {
return this.start.distanceToSquared( this.end );
},
- distance: function ( optionalTarget ) {
+ distance: function () {
return this.start.distanceTo( this.end );
| false |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | src/math/Line3.js | @@ -0,0 +1,111 @@
+/**
+ * @author bhouston / http://exocortex.com
+ */
+
+THREE.Line3 = function ( start, end ) {
+
+ this.start = ( start !== undefined ) ? start : new THREE.Vector3();
+ this.end = ( end !== undefined ) ? end : new THREE.Vector3();
+
+};
+
+THREE.extend( THREE.Line3.prototype, {
+
+ set: function ( start, end ) {
+
+ this.start.copy( start );
+ this.end.copy( end );
+
+ return this;
+
+ },
+
+ copy: function ( line ) {
+
+ this.start.copy( line.start );
+ this.end.copy( line.end );
+
+ return this;
+
+ },
+
+ center: function ( optionalTarget ) {
+
+ var result = optionalTarget || new THREE.Vector3();
+ return result.addVectors( this.start, this.end ).multiplyScalar( 0.5 );
+
+ },
+
+ delta: function ( optionalTarget ) {
+
+ var result = optionalTarget || new THREE.Vector3();
+ return result.subVectors( this.end, this.start );
+
+ },
+
+ distanceSq: function ( optionalTarget ) {
+
+ return this.start.distanceToSquared( this.end );
+
+ },
+
+ distance: function ( optionalTarget ) {
+
+ return this.start.distanceTo( this.end );
+
+ },
+
+ at: function ( t, optionalTarget ) {
+
+ var result = optionalTarget || new THREE.Vector3();
+
+ return this.delta( result ).multiplyScalar( t ).add( this.start );
+
+ },
+
+ closestPointToPoint: function() {
+
+ var startP = new THREE.Vector3();
+ var startEnd = new THREE.Vector3();
+
+ return function ( point, optionalTarget ) {
+
+ var result = optionalTarget || new THREE.Vector3();
+
+ startP.subVectors( point, this.start );
+ startEnd.subVectors( this.end, this.start );
+
+ var startEnd2 = startEnd.dot( startEnd );
+ var startEnd_startP = startEnd.dot( startP );
+
+ var t = startEnd_startP / startEnd2;
+ t = THREE.Math.clamp( t, 0, 1 );
+
+ return result.copy( startEnd ).multiplyScalar( t ).add( this.start );
+
+ };
+
+ }(),
+
+ transform: function ( matrix ) {
+
+ this.start.applyMatrix4( matrix );
+ this.end.applyMatrix4( matrix );
+
+ return this;
+
+ },
+
+ equals: function ( line ) {
+
+ return line.start.equals( this.start ) && line.end.equals( this.end );
+
+ },
+
+ clone: function () {
+
+ return new THREE.Line3().copy( this );
+
+ }
+
+} ); | true |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | test/unit/math/Line3.js | @@ -0,0 +1,63 @@
+/**
+ * @author bhouston / http://exocortex.com
+ */
+
+module( "Line3" );
+
+test( "constructor/equals", function() {
+ var a = new THREE.Line3();
+ ok( a.start.equals( zero3 ), "Passed!" );
+ ok( a.end.equals( zero3 ), "Passed!" );
+
+ a = new THREE.Line3( two3.clone(), one3.clone() );
+ ok( a.start.equals( two3 ), "Passed!" );
+ ok( a.end.equals( one3 ), "Passed!" );
+});
+
+test( "copy/equals", function() {
+ var a = new THREE.Line3( zero3.clone(), one3.clone() );
+ var b = new THREE.Line3().copy( a );
+ ok( b.start.equals( zero3 ), "Passed!" );
+ ok( b.end.equals( one3 ), "Passed!" );
+
+ // ensure that it is a true copy
+ a.start = zero3;
+ a.end = one3;
+ ok( b.start.equals( zero3 ), "Passed!" );
+ ok( b.end.equals( one3 ), "Passed!" );
+});
+
+test( "set", function() {
+ var a = new THREE.Line3();
+
+ a.set( one3, one3 );
+ ok( a.start.equals( one3 ), "Passed!" );
+ ok( a.end.equals( one3 ), "Passed!" );
+});
+
+test( "at", function() {
+ var a = new THREE.Line3( one3.clone(), new THREE.Vector3( 1, 1, 2 ) );
+
+ ok( a.at( -1 ).distanceTo( new THREE.Vector3( 1, 1, 0 ) ) < 0.0001, "Passed!" );
+ ok( a.at( 0 ).distanceTo( one3 ) < 0.0001, "Passed!" );
+ ok( a.at( 1 ).distanceTo( new THREE.Vector3( 1, 1, 2 ) ) < 0.0001, "Passed!" );
+ ok( a.at( 2 ).distanceTo( new THREE.Vector3( 1, 1, 3 ) ) < 0.0001, "Passed!" );
+});
+
+
+test( "closestPointToPoint", function() {
+ var a = new THREE.Line3( one3.clone(), new THREE.Vector3( 1, 1, 2 ) );
+
+ // nearby the ray
+ var b1 = a.closestPointToPoint( zero3 );
+ console.log( b1 );
+ ok( b1.distanceTo( new THREE.Vector3( 1, 1, 1 ) ) < 0.0001, "Passed!" );
+
+ // nearby the ray
+ var b = a.closestPointToPoint( new THREE.Vector3( 1, 1, 5 ) );
+ ok( b.distanceTo( new THREE.Vector3( 1, 1, 2 ) ) < 0.0001, "Passed!" );
+
+ // exactly on the ray
+ var c = a.closestPointToPoint( one3 );
+ ok( c.distanceTo( one3 ) < 0.0001, "Passed!" );
+});
\ No newline at end of file | true |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | test/unit/unittests_sources.html | @@ -17,6 +17,7 @@
<script src="../../src/math/Vector2.js"></script>
<script src="../../src/math/Vector3.js"></script>
<script src="../../src/math/Vector4.js"></script>
+ <script src="../../src/math/Line3.js"></script>
<script src="../../src/math/Box2.js"></script>
<script src="../../src/math/Box3.js"></script>
<script src="../../src/math/Matrix3.js"></script>
@@ -25,7 +26,7 @@
<script src="../../src/math/Frustum.js"></script>
<script src="../../src/math/Plane.js"></script>
<script src="../../src/math/Sphere.js"></script>
- <script src="../../src/math/Math.js"></script>
+ <script src="../../src/math/Math.js"></script>
<script src="../../src/math/Triangle.js"></script>
<!-- add class-based unit tests below -->
@@ -40,6 +41,7 @@
<script src="math/Vector2.js"></script>
<script src="math/Vector3.js"></script>
<script src="math/Vector4.js"></script>
+ <script src="math/Line3.js"></script>
<script src="math/Quaternion.js"></script>
<script src="math/Matrix3.js"></script>
<script src="math/Matrix4.js"></script> | true |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | test/unit/unittests_three-math.html | @@ -25,6 +25,7 @@
<script src="math/Vector2.js"></script>
<script src="math/Vector3.js"></script>
<script src="math/Vector4.js"></script>
+ <script src="math/Line3.js"></script>
<script src="math/Quaternion.js"></script>
<script src="math/Matrix3.js"></script>
<script src="math/Matrix4.js"></script> | true |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | test/unit/unittests_three.html | @@ -25,6 +25,7 @@
<script src="math/Vector2.js"></script>
<script src="math/Vector3.js"></script>
<script src="math/Vector4.js"></script>
+ <script src="math/Line3.js"></script>
<script src="math/Quaternion.js"></script>
<script src="math/Matrix3.js"></script>
<script src="math/Matrix4.js"></script> | true |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | test/unit/unittests_three.min.html | @@ -25,6 +25,7 @@
<script src="math/Vector2.js"></script>
<script src="math/Vector3.js"></script>
<script src="math/Vector4.js"></script>
+ <script src="math/Line3.js"></script>
<script src="math/Quaternion.js"></script>
<script src="math/Matrix3.js"></script>
<script src="math/Matrix4.js"></script> | true |
Other | mrdoob | three.js | 4d5177f777a48aaabbff28599e5f17e2028630bb.json | add initial Line3.js with unit tests. | utils/build/includes/math.json | @@ -5,6 +5,7 @@
"src/math/Vector2.js",
"src/math/Vector3.js",
"src/math/Vector4.js",
+ "src/math/Line3.js",
"src/math/Box2.js",
"src/math/Box3.js",
"src/math/Matrix3.js", | true |
Other | mrdoob | three.js | 82af7f0c9fc60e50d1c82c3eaf7bc6f5f9275076.json | add EMCASCript5 compatibility to THREE.extend.
Signed-off-by: Ben Houston <ben@exocortex.com> | src/Three.js | @@ -48,9 +48,27 @@ String.prototype.trim = String.prototype.trim || function () {
// based on https://github.com/documentcloud/underscore/blob/bf657be243a075b5e72acc8a83e6f12a564d8f55/underscore.js#L767
THREE.extend = function ( obj, source ) {
- for (var prop in source) {
+ // ECMAScript5 compatibility based on: http://www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible/
+ if ( Object.keys ) {
- obj[prop] = source[prop];
+ Object.keys( source ).forEach(
+ function ( prop ) {
+ Object.defineProperty( obj, prop, Object.getOwnPropertyDescriptor( source, prop ) );
+ }
+ );
+
+ }
+ else {
+
+ for ( var prop in source ) {
+
+ if ( source.hasOwnProperty( prop ) ) {
+
+ obj[prop] = source[prop];
+
+ }
+
+ }
}
| false |
Other | mrdoob | three.js | a685230753ffc8709f860af11824fb84829f2ee3.json | remove stray console.log() from Line3 unit test. | test/unit/math/Line3.js | @@ -55,7 +55,6 @@ test( "closestPointToPoint/closestPointToPointParameter", function() {
// nearby the ray
ok( a.closestPointToPointParameter( zero3.clone(), false ) == -1, "Passed!" );
var b2 = a.closestPointToPoint( zero3.clone(), false );
- console.log( b2 );
ok( b2.distanceTo( new THREE.Vector3( 1, 1, 0 ) ) < 0.0001, "Passed!" );
// nearby the ray | false |
Other | mrdoob | three.js | b9afd9865de494fce9638ef612aeab0306544a07.json | apply unit conversion to position as well | examples/js/loaders/ColladaLoader.js | @@ -847,6 +847,7 @@ THREE.ColladaLoader = function () {
obj.scale = props[ 2 ];
// unit conversion
+ obj.position.multiplyScalar(colladaUnit);
obj.scale.multiplyScalar(colladaUnit);
if ( options.centerGeometry && obj.geometry ) { | false |
Other | mrdoob | three.js | ce7425f2692abaa1a6b3a16828f7aa343657bef7.json | Remove redundant initialisation | src/extras/helpers/DirectionalLightHelper.js | @@ -72,11 +72,6 @@ THREE.DirectionalLightHelper = function ( light, sphereSize ) {
this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
this.targetLine.properties.isGizmo = true;
- }
- else {
-
- this.targetSphere = null;
-
}
// | true |
Other | mrdoob | three.js | ce7425f2692abaa1a6b3a16828f7aa343657bef7.json | Remove redundant initialisation | src/extras/helpers/SpotLightHelper.js | @@ -91,11 +91,6 @@ THREE.SpotLightHelper = function ( light, sphereSize ) {
this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
this.targetLine.properties.isGizmo = true;
- }
- else {
-
- this.targetSphere = null;
-
}
// | true |
Other | mrdoob | three.js | 62778396082a830f695cdd2ca17efbe14c8703f5.json | Fix bug in SpotLightHelper
Same as in DirectionalLightHelper | src/extras/helpers/SpotLightHelper.js | @@ -91,6 +91,11 @@ THREE.SpotLightHelper = function ( light, sphereSize ) {
this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
this.targetLine.properties.isGizmo = true;
+ }
+ else {
+
+ this.targetSphere = null;
+
}
//
@@ -127,15 +132,20 @@ THREE.SpotLightHelper.prototype.update = function () {
this.lightRays.material.color.copy( this.color );
this.lightCone.material.color.copy( this.color );
- this.targetSphere.material.color.copy( this.color );
- this.targetLine.material.color.copy( this.color );
+ // Only update targetSphere and targetLine if available
+ if ( this.targetSphere ) {
- // update target line vertices
+ this.targetSphere.material.color.copy( this.color );
+ this.targetLine.material.color.copy( this.color );
- this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
- this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
+ // update target line vertices
- this.targetLine.geometry.computeLineDistances();
- this.targetLine.geometry.verticesNeedUpdate = true;
+ this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
+ this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
+
+ this.targetLine.geometry.computeLineDistances();
+ this.targetLine.geometry.verticesNeedUpdate = true;
+
+ }
}; | false |
Other | mrdoob | three.js | 82dd6c5a237aab59e1261ec114a5e40c82f00cfc.json | Fix bug in DirectionalLightHelper
If light.target.properties.targetInverse is false, no targetLine and
targetSphere is created, we can't update their values on update()! | src/extras/helpers/DirectionalLightHelper.js | @@ -72,6 +72,11 @@ THREE.DirectionalLightHelper = function ( light, sphereSize ) {
this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
this.targetLine.properties.isGizmo = true;
+ }
+ else {
+
+ this.targetSphere = null;
+
}
//
@@ -99,16 +104,21 @@ THREE.DirectionalLightHelper.prototype.update = function () {
this.lightSphere.material.color.copy( this.color );
this.lightRays.material.color.copy( this.color );
- this.targetSphere.material.color.copy( this.color );
- this.targetLine.material.color.copy( this.color );
+ // Only update targetSphere and targetLine if available
+ if ( this.targetSphere ) {
- // update target line vertices
+ this.targetSphere.material.color.copy( this.color );
+ this.targetLine.material.color.copy( this.color );
- this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
- this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
+ // update target line vertices
- this.targetLine.geometry.computeLineDistances();
- this.targetLine.geometry.verticesNeedUpdate = true;
+ this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
+ this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
+
+ this.targetLine.geometry.computeLineDistances();
+ this.targetLine.geometry.verticesNeedUpdate = true;
+
+ }
}
| false |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | src/renderers/WebGLRenderer2.js | @@ -35,10 +35,10 @@ THREE.WebGLRenderer2 = function ( parameters ) {
var renderer = new THREE.WebGLRenderer2.LowLevelRenderer(parameters);
- var meshRenderer = new THREE.WebGLRenderer2.MeshObjectRenderer(renderer, info);
- var particleRenderer = new THREE.WebGLRenderer2.ParticleObjectRenderer(renderer, info);
- var lineRenderer = new THREE.WebGLRenderer2.LineObjectRenderer(renderer, info);
- var ribbonRenderer = new THREE.WebGLRenderer2.RibbonObjectRenderer(renderer, info);
+ var meshRenderer = new THREE.WebGLRenderer2.MeshRenderer(renderer, info);
+ var particleRenderer = new THREE.WebGLRenderer2.ParticleRenderer(renderer, info);
+ var lineRenderer = new THREE.WebGLRenderer2.LineRenderer(renderer, info);
+ var ribbonRenderer = new THREE.WebGLRenderer2.RibbonRenderer(renderer, info);
var shaderBuilder = new THREE.WebGLRenderer2.ShaderBuilder(renderer, info);
| true |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | src/renderers/webgl/objects/LineRenderer.js | @@ -1,13 +1,13 @@
-THREE.WebGLRenderer2.LineObjectRenderer = function(lowlevelrenderer, info){
+THREE.WebGLRenderer2.LineRenderer = function(lowlevelrenderer, info){
THREE.WebGLRenderer2.Object3DObjectRenderer.call( this, lowlevelrenderer, info );
};
-THREE.WebGLRenderer2.LineObjectRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
+THREE.WebGLRenderer2.LineRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
-THREE.WebGLRenderer2.LineObjectRenderer.prototype.createBuffers = function( geometry ) {
+THREE.WebGLRenderer2.LineRenderer.prototype.createBuffers = function( geometry ) {
var renderer = this.renderer;
geometry.__webglVertexBuffer = renderer.createBuffer();
@@ -17,7 +17,7 @@ THREE.WebGLRenderer2.LineObjectRenderer.prototype.createBuffers = function( geom
this.info.memory.geometries ++;
};
-THREE.WebGLRenderer2.LineObjectRenderer.prototype.initBuffers = function( geometry, object ) {
+THREE.WebGLRenderer2.LineRenderer.prototype.initBuffers = function( geometry, object ) {
var nvertices = geometry.vertices.length;
@@ -31,7 +31,7 @@ THREE.WebGLRenderer2.LineObjectRenderer.prototype.initBuffers = function( geomet
};
-THREE.WebGLRenderer2.LineObjectRenderer.prototype.setBuffers = function( geometry, object) {
+THREE.WebGLRenderer2.LineRenderer.prototype.setBuffers = function( geometry, object) {
var renderer = this.renderer;
var v, c, d, vertex, offset, color, | true |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | src/renderers/webgl/objects/MeshRenderer.js | @@ -1,13 +1,13 @@
-THREE.WebGLRenderer2.MeshObjectRenderer = function(lowlevelrenderer, info){
+THREE.WebGLRenderer2.MeshRenderer = function(lowlevelrenderer, info){
THREE.WebGLRenderer2.Object3DObjectRenderer.call( this, lowlevelrenderer, info );
};
-THREE.WebGLRenderer2.MeshObjectRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
+THREE.WebGLRenderer2.MeshRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
-THREE.WebGLRenderer2.MeshObjectRenderer.prototype.createBuffers = function( geometryGroup ) {
+THREE.WebGLRenderer2.MeshRenderer.prototype.createBuffers = function( geometryGroup ) {
var renderer = this.renderer;
geometryGroup.__webglVertexBuffer = renderer.createBuffer();
@@ -53,7 +53,7 @@ THREE.WebGLRenderer2.MeshObjectRenderer.prototype.createBuffers = function( geom
};
-THREE.WebGLRenderer2.MeshObjectRenderer.prototype.initBuffers = function( geometryGroup, object ) {
+THREE.WebGLRenderer2.MeshRenderer.prototype.initBuffers = function( geometryGroup, object ) {
var geometry = object.geometry,
faces3 = geometryGroup.faces3,
@@ -207,7 +207,7 @@ THREE.WebGLRenderer2.MeshObjectRenderer.prototype.initBuffers = function( geomet
-THREE.WebGLRenderer2.MeshObjectRenderer.prototype.setBuffers = function( geometryGroup, object, dispose, material ) {
+THREE.WebGLRenderer2.MeshRenderer.prototype.setBuffers = function( geometryGroup, object, dispose, material ) {
if ( ! geometryGroup.__inittedArrays ) {
| true |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | src/renderers/webgl/objects/Object3DRenderer.js | @@ -1,19 +1,19 @@
-THREE.WebGLRenderer2.Object3DObjectRenderer = function(lowlevelrenderer, info){
+THREE.WebGLRenderer2.Object3DRenderer = function(lowlevelrenderer, info){
this.renderer = lowlevelrenderer;
this.info = info;
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.getBufferMaterial = function( object, geometryGroup ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.getBufferMaterial = function( object, geometryGroup ) {
return object.material instanceof THREE.MeshFaceMaterial
? object.material.materials[ geometryGroup.materialIndex ]
: object.material;
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.bufferGuessUVType = function( material ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.bufferGuessUVType = function( material ) {
// material must use some texture to require uvs
@@ -27,7 +27,7 @@ THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.bufferGuessUVType = functi
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.bufferGuessNormalType = function ( material ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.bufferGuessNormalType = function ( material ) {
// only MeshBasicMaterial and MeshDepthMaterial don't need normals
@@ -49,14 +49,14 @@ THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.bufferGuessNormalType = fu
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.materialNeedsSmoothNormals = function ( material ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.materialNeedsSmoothNormals = function ( material ) {
return material && material.shading !== undefined && material.shading === THREE.SmoothShading;
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.bufferGuessVertexColorType = function ( material ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.bufferGuessVertexColorType = function ( material ) {
if ( material.vertexColors ) {
@@ -69,7 +69,7 @@ THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.bufferGuessVertexColorType
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.initCustomAttributes = function( geometry, object ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.initCustomAttributes = function( geometry, object ) {
var nvertices = geometry.vertices.length;
@@ -117,7 +117,7 @@ THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.initCustomAttributes = fun
};
-THREE.WebGLRenderer2.Object3DObjectRenderer.prototype.numericalSort = function( a, b ) {
+THREE.WebGLRenderer2.Object3DRenderer.prototype.numericalSort = function( a, b ) {
return b[ 0 ] - a[ 0 ];
| true |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | src/renderers/webgl/objects/ParticleRenderer.js | @@ -1,12 +1,12 @@
-THREE.WebGLRenderer2.ParticleObjectRenderer = function(lowlevelrenderer, info){
+THREE.WebGLRenderer2.ParticleRenderer = function(lowlevelrenderer, info){
THREE.WebGLRenderer2.Object3DObjectRenderer.call( this, lowlevelrenderer, info );
};
-THREE.WebGLRenderer2.ParticleObjectRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
+THREE.WebGLRenderer2.ParticleRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
-THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.createBuffers = function( geometry ) {
+THREE.WebGLRenderer2.ParticleRenderer.prototype.createBuffers = function( geometry ) {
var renderer = this.renderer;
geometry.__webglVertexBuffer = renderer.createBuffer();
@@ -15,7 +15,7 @@ THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.createBuffers = function(
this.info.memory.geometries ++;
};
-THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.initBuffers = function( geometry, object ) {
+THREE.WebGLRenderer2.ParticleRenderer.prototype.initBuffers = function( geometry, object ) {
var nvertices = geometry.vertices.length;
@@ -31,7 +31,7 @@ THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.initBuffers = function( ge
};
-THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.setBuffers = function( geometry, object , projectionScreenMatrix) {
+THREE.WebGLRenderer2.ParticleRenderer.prototype.setBuffers = function( geometry, object , projectionScreenMatrix) {
var renderer = this.renderer;
var v, c, vertex, offset, index, color,
@@ -56,8 +56,8 @@ THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.setBuffers = function( geo
a, ca, cal, value,
customAttribute;
- var _projScreenMatrixPS = THREE.WebGLRenderer2.ParticleObjectRenderer._m1,
- _vector3 = THREE.WebGLRenderer2.ParticleObjectRenderer._v1;
+ var _projScreenMatrixPS = THREE.WebGLRenderer2.ParticleRenderer._m1,
+ _vector3 = THREE.WebGLRenderer2.ParticleRenderer._v1;
if ( object.sortParticles ) {
@@ -354,5 +354,5 @@ THREE.WebGLRenderer2.ParticleObjectRenderer.prototype.setBuffers = function( geo
};
-THREE.WebGLRenderer2.ParticleObjectRenderer._m1 = new THREE.Matrix4();
-THREE.WebGLRenderer2.ParticleObjectRenderer._v1 = new THREE.Vector3();
\ No newline at end of file
+THREE.WebGLRenderer2.ParticleRenderer._m1 = new THREE.Matrix4();
+THREE.WebGLRenderer2.ParticleRenderer._v1 = new THREE.Vector3();
\ No newline at end of file | true |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | src/renderers/webgl/objects/RibbonRenderer.js | @@ -1,12 +1,12 @@
-THREE.WebGLRenderer2.RibbonObjectRenderer = function(lowlevelrenderer, info){
+THREE.WebGLRenderer2.RibbonRenderer = function(lowlevelrenderer, info){
THREE.WebGLRenderer2.Object3DObjectRenderer.call( this, lowlevelrenderer, info );
};
-THREE.WebGLRenderer2.RibbonObjectRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
+THREE.WebGLRenderer2.RibbonRenderer.prototype = Object.create( THREE.WebGLRenderer2.Object3DObjectRenderer.prototype );
-THREE.WebGLRenderer2.RibbonObjectRenderer.prototype.createBuffers = function( geometry ) {
+THREE.WebGLRenderer2.RibbonRenderer.prototype.createBuffers = function( geometry ) {
var renderer = this.renderer;
geometry.__webglVertexBuffer = renderer.createBuffer();
@@ -16,7 +16,7 @@ THREE.WebGLRenderer2.RibbonObjectRenderer.prototype.createBuffers = function( ge
this.info.memory.geometries ++;
};
-THREE.WebGLRenderer2.RibbonObjectRenderer.prototype.initBuffers = function( geometry, object ) {
+THREE.WebGLRenderer2.RibbonRenderer.prototype.initBuffers = function( geometry, object ) {
var nvertices = geometry.vertices.length;
@@ -31,7 +31,7 @@ THREE.WebGLRenderer2.RibbonObjectRenderer.prototype.initBuffers = function( geom
};
-THREE.WebGLRenderer2.RibbonObjectRenderer.prototype.setBuffers = function( geometry, object , projectionScreenMatrix) {
+THREE.WebGLRenderer2.RibbonRenderer.prototype.setBuffers = function( geometry, object , projectionScreenMatrix) {
var renderer = this.renderer;
var v, c, n, vertex, offset, color, normal,
| true |
Other | mrdoob | three.js | b17b34186081daaf63072043dfabda179aa85e92.json | rename the object renderers again | utils/includes/common.json | @@ -74,16 +74,16 @@
"../src/scenes/Fog.js",
"../src/scenes/FogExp2.js",
"../src/renderers/CanvasRenderer.js",
- "../src/renderers/WebGLShaders.js",
"../src/renderers/WebGLRenderer.js",
+ "../src/renderers/WebGLShaders.js",
"../src/renderers/WebGLRenderer2.js",
"../src/renderers/webgl/LowLevelRenderer.js",
"../src/renderers/webgl/ShaderBuilder.js",
- "../src/renderers/webgl/objects/Object3DObjectRenderer.js",
- "../src/renderers/webgl/objects/MeshObjectRenderer.js",
- "../src/renderers/webgl/objects/ParticleObjectRenderer.js",
- "../src/renderers/webgl/objects/LineObjectRenderer.js",
- "../src/renderers/webgl/objects/RibbonObjectRenderer.js",
+ "../src/renderers/webgl/objects/Object3DRenderer.js",
+ "../src/renderers/webgl/objects/MeshRenderer.js",
+ "../src/renderers/webgl/objects/ParticleRenderer.js",
+ "../src/renderers/webgl/objects/LineRenderer.js",
+ "../src/renderers/webgl/objects/RibbonRenderer.js",
"../src/renderers/WebGLRenderTarget.js",
"../src/renderers/WebGLRenderTargetCube.js",
"../src/renderers/renderables/RenderableVertex.js", | true |
Other | mrdoob | three.js | 911146dba1eb2e5e43eb838757ef27fe958407ca.json | add Plane.flip() plus unit test. | src/math/Plane.js | @@ -74,6 +74,15 @@ THREE.Plane.prototype = {
},
+ flip: function () {
+
+ this.constant *= -1;
+ this.normal.negate();
+
+ return this;
+
+ },
+
distanceToPoint: function ( point ) {
return this.normal.dot( point ) + this.constant; | true |
Other | mrdoob | three.js | 911146dba1eb2e5e43eb838757ef27fe958407ca.json | add Plane.flip() plus unit test. | test/unit/math/Plane.js | @@ -94,6 +94,18 @@ test( "normalize", function() {
ok( a.constant == 1, "Passed!" );
});
+test( "flip/distanceToPoint", function() {
+ var a = new THREE.Plane( new THREE.Vector3( 2, 0, 0 ), -2 );
+
+ a.normalize();
+ ok( a.distanceToPoint( new THREE.Vector3( 4, 0, 0 ) ) === 3, "Passed!" );
+ ok( a.distanceToPoint( new THREE.Vector3( 1, 0, 0 ) ) === 0, "Passed!" );
+
+ a.flip();
+ ok( a.distanceToPoint( new THREE.Vector3( 4, 0, 0 ) ) === -3, "Passed!" );
+ ok( a.distanceToPoint( new THREE.Vector3( 1, 0, 0 ) ) === 0, "Passed!" );
+});
+
test( "distanceToPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 2, 0, 0 ), -2 );
| true |
Other | mrdoob | three.js | 367fb776a190e9957e82068fb65f5cd335abc1bf.json | remove unused variables from Raycaster. | src/core/Raycaster.js | @@ -34,8 +34,6 @@
};
- var v0 = new THREE.Vector3(), v1 = new THREE.Vector3(), v2 = new THREE.Vector3();
-
// http://www.blackpawn.com/texts/pointinpoly/default.html
var intersectObject = function ( object, raycaster, intersects ) { | false |
Other | mrdoob | three.js | e3ccd9682678d1423ad1bba4120593db644f6f9d.json | update lowlevel renderer | src/renderers/webgl/renderer.js | @@ -20,6 +20,9 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
_clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 ),
_clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
+ var _currentWidth = 0,
+ _currentHeight = 0;
+
var _gl;
@@ -30,11 +33,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
initGL();
- setDefaultGLState();
-
- this.context = _gl;
-
-
+ setDefaultGLState();
var _maxTextures = _gl.getParameter( _gl.MAX_TEXTURE_IMAGE_UNITS );
var _maxVertexTextures = _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
@@ -72,14 +71,6 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
_oldPolygonOffsetFactor = null,
_oldPolygonOffsetUnits = null,
_currentFramebuffer = null;
-
- this.autoScaleCubemaps = true;
- this.supportsBoneTextures = _supportsBoneTextures;
- this.precision = _precision;
- this.maxVertexUniformVectors = _gl.getParameter( _gl.MAX_VERTEX_UNIFORM_VECTORS );
-
- this.currentWidth = 0;
- this.currentHeight = 0;
function initGL () {
@@ -171,39 +162,39 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.getContext = function () {
+ function getContext() {
return _gl;
};
- this.getDomElement = function(){
+ function getDomElement(){
return _canvas;
}
- this.supportsVertexTextures = function () {
+ function supportsVertexTextures() {
return _supportsVertexTextures;
};
- this.getMaxAnisotropy = function () {
+ function getMaxAnisotropy() {
return _maxAnisotropy;
};
- this.setSize = function ( width, height ) {
+ function setSize( width, height ) {
_canvas.width = width;
_canvas.height = height;
- this.setViewport( 0, 0, _canvas.width, _canvas.height );
+ setViewport( 0, 0, _canvas.width, _canvas.height );
};
- this.setViewport = function ( x, y, width, height ) {
+ function setViewport( x, y, width, height ) {
_viewportX = x !== undefined ? x : 0;
_viewportY = y !== undefined ? y : 0;
@@ -215,21 +206,21 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setScissor = function ( x, y, width, height ) {
+ function setScissor( x, y, width, height ) {
_gl.scissor( x, y, width, height );
};
- this.enableScissorTest = function ( enable ) {
+ function enableScissorTest( enable ) {
enable ? _gl.enable( _gl.SCISSOR_TEST ) : _gl.disable( _gl.SCISSOR_TEST );
};
// Clearing
- this.setClearColorHex = function ( hex, alpha ) {
+ function setClearColorHex( hex, alpha ) {
_clearColor.setHex( hex );
_clearAlpha = alpha;
@@ -238,7 +229,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setClearColor = function ( color, alpha ) {
+ function setClearColor( color, alpha ) {
_clearColor.copy( color );
_clearAlpha = alpha;
@@ -247,19 +238,19 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.getClearColor = function () {
+ function getClearColor() {
return _clearColor;
};
- this.getClearAlpha = function () {
+ function getClearAlpha() {
return _clearAlpha;
};
- this.clear = function ( color, depth, stencil ) {
+ function clear( color, depth, stencil ) {
var bits = 0;
@@ -271,102 +262,102 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.clearTarget = function ( renderTarget, color, depth, stencil ) {
+ function clearTarget( renderTarget, color, depth, stencil ) {
- this.setRenderTarget( renderTarget );
- this.clear( color, depth, stencil );
+ setRenderTarget( renderTarget );
+ clear( color, depth, stencil );
};
- this.deleteBuffer = function(buffer){
+ function deleteBuffer(buffer){
_gl.deleteBuffer(buffer);
};
- this.deleteTexture = function(texture){
+ function deleteTexture(texture){
_gl.deleteTexture( texture );
};
- this.deleteFramebuffer = function(Framebuffer){
+ function deleteFramebuffer(Framebuffer){
_gl.deleteFramebuffer(Framebuffer);
};
- this.deleteRenderbuffer = function(RenderBuffer){
+ function deleteRenderbuffer(RenderBuffer){
_gl.deleteRenderbuffer(RenderBuffer);
};
- this.deleteProgram = function(RenderBuffer){
+ function deleteProgram(RenderBuffer){
_gl.deleteProgram(RenderBuffer);
};
- this.createBuffer = function(){
+ function createBuffer(){
return _gl.createBuffer();
};
- this.setStaticArrayBuffer = function(buffer,data){
+ function setStaticArrayBuffer(buffer,data){
- this.bindArrayBuffer( buffer );
+ bindArrayBuffer( buffer );
_gl.bufferData( _gl.ARRAY_BUFFER, data, _gl.STATIC_DRAW );
};
- this.setStaticIndexBuffer = function(buffer,data){
+ function setStaticIndexBuffer(buffer,data){
- this.bindElementArrayBuffer( buffer );
+ bindElementArrayBuffer( buffer );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, data, _gl.STATIC_DRAW );
};
- this.setDynamicArrayBuffer = function(buffer,data){
+ function setDynamicArrayBuffer(buffer,data){
- this.bindArrayBuffer( buffer );
+ bindArrayBuffer( buffer );
_gl.bufferData( _gl.ARRAY_BUFFER, data, _gl.DYNAMIC_DRAW );
};
- this.setDynamicIndexBuffer = function(buffer,data){
+ function setDynamicIndexBuffer(buffer,data){
- this.bindElementArrayBuffer( buffer );
+ bindElementArrayBuffer( buffer );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, data, _gl.DYNAMIC_DRAW );
};
- this.drawTriangles = function(count){
+ function drawTriangles(count){
_gl.drawArrays( _gl.TRIANGLES, 0, count );
};
- this.drawLines = function(count){
+ function drawLines(count){
_gl.drawArrays( _gl.LINES, 0, count );
};
- this.drawLineStrip = function(count){
+ function drawLineStrip(count){
_gl.drawArrays( _gl.LINE_STRIP, 0, count );
};
- this.drawPoints = function(count){
+ function drawPoints(count){
_gl.drawArrays( _gl.POINTS, 0, count );
};
- this.drawTriangleElements = function(buffer,count,offset){
- this.bindElementArrayBuffer( buffer );
+ function drawTriangleElements(buffer,count,offset){
+ bindElementArrayBuffer( buffer );
_gl.drawElements( _gl.TRIANGLES, count, _gl.UNSIGNED_SHORT, offset ); // 2 bytes per Uint16
};
- this.drawLineElements = function(buffer,count,offset){
- this.bindElementArrayBuffer( buffer );
+ function drawLineElements(buffer,count,offset){
+ bindElementArrayBuffer( buffer );
_gl.drawElements( _gl.LINES, count, _gl.UNSIGNED_SHORT, offset ); // 2 bytes per Uint16
};
- var _boundBuffer =undefined;
- this.bindArrayBuffer = function(buffer){
+ var _boundBuffer;
+ function bindArrayBuffer(buffer){
if (_boundBuffer != buffer){
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
_boundBuffer = buffer;
}
};
- this.bindElementArrayBuffer = function(buffer){
+ function bindElementArrayBuffer(buffer){
if (_boundBuffer != buffer){
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffer );
@@ -376,7 +367,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.enableAttribute = function enableAttribute( attribute ) {
+ function enableAttribute( attribute ) {
if ( ! _enabledAttributes[ attribute ] ) {
@@ -389,7 +380,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
- this.disableAttributes = function disableAttributes() {
+ function disableAttributes() {
for ( var attribute in _enabledAttributes ) {
@@ -404,133 +395,137 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.getAttribLocation = function( program, id ){
+ function getAttribLocation( program, id ){
return _gl.getAttribLocation( program, id );
}
- this.setFloatAttribute = function(index,buffer,size,offset){
+ function setFloatAttribute(index,buffer,size,offset){
- this.bindArrayBuffer( buffer );
- this.enableAttribute( index );
+ bindArrayBuffer( buffer );
+ enableAttribute( index );
_gl.vertexAttribPointer( index, size, _gl.FLOAT, false, 0, offset );
};
- this.getUniformLocation= function( program, id ){
+ function getUniformLocation( program, id ){
return _gl.getUniformLocation( program, id );
}
- this.uniform1i = function(uniform,value){
+ function uniform1i(uniform,value){
_gl.uniform1i( uniform, value );
};
- this.uniform1f = function(uniform,value){
+ function uniform1f(uniform,value){
_gl.uniform1f( uniform, value );
};
- this.uniform2f = function(uniform,value1, value2){
+ function uniform2f(uniform,value1, value2){
_gl.uniform2f( location, value1, value2 );
};
- this.uniform3f = function(uniform, value1, value2, value3){
+ function uniform3f(uniform, value1, value2, value3){
_gl.uniform3f( uniform, value1, value2, value3 );
};
- this.uniform4f = function(uniform, value1, value2, value3, value4){
+ function uniform4f(uniform, value1, value2, value3, value4){
_gl.uniform4f( uniform, value1, value2, value3, value4);
};
- this.uniform1iv = function(uniform,value){
+ function uniform1iv(uniform,value){
_gl.uniform1iv( uniform, value );
};
- this.uniform2iv = function(uniform,value){
+ function uniform2iv(uniform,value){
_gl.uniform2iv( uniform, value );
};
- this.uniform3iv = function(uniform,value){
+ function uniform3iv(uniform,value){
_gl.uniform3iv( uniform, value );
};
- this.uniform1fv = function(uniform,value){
+ function uniform1fv(uniform,value){
_gl.uniform1fv( uniform, value );
};
- this.uniform2fv = function(uniform,value){
+ function uniform2fv(uniform,value){
_gl.uniform2fv( uniform, value );
};
- this.uniform3fv = function(uniform,value){
+ function uniform3fv(uniform,value){
_gl.uniform3fv( uniform, value );
};
- this.uniform4fv = function(uniform,value){
+ function uniform4fv(uniform,value){
_gl.uniform3fv( uniform, value );
};
- this.uniformMatrix3fv = function(location,value){
+ function uniformMatrix3fv(location,value){
_gl.uniformMatrix3fv( location, false, value );
};
- this.uniformMatrix4fv = function(location,value){
+ function uniformMatrix4fv(location,value){
_gl.uniformMatrix4fv( location, false, value );
};
- this.useProgram = function(program){
+ function useProgram(program){
_gl.useProgram( program );
};
- this.setFaceCulling = function ( cullFace, frontFace ) {
-
- if ( cullFace ) {
+ function setFaceCulling( cullFace, frontFaceDirection ) {
- if ( !frontFace || frontFace === "ccw" ) {
+ if ( cullFace === THREE.CullFaceNone ) {
- _gl.frontFace( _gl.CCW );
+ _gl.disable( _gl.CULL_FACE );
- } else {
+ } else {
+
+ if ( frontFaceDirection === THREE.FrontFaceDirectionCW ) {
_gl.frontFace( _gl.CW );
+ } else {
+
+ _gl.frontFace( _gl.CCW );
+
}
- if( cullFace === "back" ) {
+ if ( cullFace === THREE.CullFaceBack ) {
_gl.cullFace( _gl.BACK );
- } else if( cullFace === "front" ) {
+ } else if ( cullFace === THREE.CullFaceFront ) {
_gl.cullFace( _gl.FRONT );
@@ -542,15 +537,11 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
_gl.enable( _gl.CULL_FACE );
- } else {
-
- _gl.disable( _gl.CULL_FACE );
-
}
};
- this.setMaterialFaces = function ( material ) {
+ function setMaterialFaces( material ) {
var doubleSided = material.side === THREE.DoubleSide;
var flipSided = material.side === THREE.BackSide;
@@ -589,7 +580,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setPolygonOffset = function setPolygonOffset ( polygonoffset, factor, units ) {
+ function setPolygonOffset ( polygonoffset, factor, units ) {
if ( _oldPolygonOffset !== polygonoffset ) {
@@ -618,10 +609,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
-
-
-
- this.setBlending = function ( blending, blendEquation, blendSrc, blendDst ) {
+ function setBlending( blending, blendEquation, blendSrc, blendDst ) {
if ( blending !== _oldBlending ) {
@@ -696,7 +684,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
- this.setDepthTest = function ( depthTest ) {
+ function setDepthTest( depthTest ) {
if ( _oldDepthTest !== depthTest ) {
@@ -716,7 +704,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setDepthWrite = function ( depthWrite ) {
+ function setDepthWrite( depthWrite ) {
if ( _oldDepthWrite !== depthWrite ) {
@@ -728,7 +716,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setTexture = function ( texture, slot ) {
+ function setTexture( texture, slot ) {
if ( texture.needsUpdate ) {
@@ -788,7 +776,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setCubeTexture = function( texture, slot ,autoScaleCubemaps) {
+ function setCubeTexture( texture, slot ,autoScaleCubemaps) {
if ( texture.image.length === 6 ) {
@@ -953,7 +941,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setRenderTarget = function ( renderTarget ) {
+ function setRenderTarget( renderTarget ) {
var isCube = ( renderTarget instanceof THREE.WebGLRenderTargetCube );
@@ -1067,8 +1055,8 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
}
- this.currentWidth = width;
- this.currentHeight = height;
+ _currentWidth = width;
+ _currentHeight = height;
};
@@ -1101,7 +1089,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.updateRenderTargetMipmap = function updateRenderTargetMipmap ( renderTarget ) {
+ function updateRenderTargetMipmap ( renderTarget ) {
if ( renderTarget instanceof THREE.WebGLRenderTargetCube ) {
@@ -1119,7 +1107,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.setCubeTextureDynamic = function setCubeTextureDynamic ( texture, slot ) {
+ function setCubeTextureDynamic ( texture, slot ) {
_gl.activeTexture( _gl.TEXTURE0 + slot );
_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.__webglTexture );
@@ -1131,7 +1119,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
// Map three.js constants to WebGL constants
- var paramThreeToGL = this.paramThreeToGL = function paramThreeToGL ( p ) {
+ function paramThreeToGL ( p ) {
if ( p === THREE.RepeatWrapping ) return _gl.REPEAT;
if ( p === THREE.ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE;
@@ -1194,7 +1182,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.compileShader = function(vertexShader, fragmentShader){
+ function compileShader(vertexShader, fragmentShader){
var program = _gl.createProgram();
@@ -1221,7 +1209,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
};
- this.resetState = function(){
+ function resetState(){
_oldBlending = -1;
_oldDepthTest = -1;
@@ -1280,7 +1268,7 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
- var setLineWidth = this.setLineWidth = function setLineWidth ( width ) {
+ function setLineWidth ( width ) {
if ( width !== _oldLineWidth ) {
@@ -1291,6 +1279,97 @@ THREE.WebGLRenderer2.LowLevelRenderer = function(parameters){
}
};
+
+
+ this.context = _gl;
+
+ this.autoScaleCubemaps = true;
+ this.supportsBoneTextures = _supportsBoneTextures;
+ this.precision = _precision;
+ this.maxVertexUniformVectors = _gl.getParameter( _gl.MAX_VERTEX_UNIFORM_VECTORS );
+
+ // Methods
+ this.getContext = getContext;
+ this.getDomElement = getDomElement;
+ this.supportsVertexTextures = supportsVertexTextures;
+ this.getMaxAnisotropy = getMaxAnisotropy;
+
+ this.setSize = setSize;
+ this.setViewport = setViewport;
+ this.setScissor = setScissor;
+ this.enableScissorTest = enableScissorTest;
+
+ this.setClearColorHex = setClearColorHex;
+ this.setClearColor = setClearColor;
+ this.getClearColor = getClearColor;
+ this.getClearAlpha = getClearAlpha;
+ this.clear = clear;
+ this.clearTarget = clearTarget;
+
+ this.deleteBuffer = deleteBuffer;
+ this.deleteTexture = deleteTexture;
+ this.deleteFramebuffer = deleteFramebuffer;
+ this.deleteRenderbuffer = deleteRenderbuffer;
+ this.deleteProgram = deleteProgram;
+
+ this.createBuffer = createBuffer;
+ this.setStaticArrayBuffer = setStaticArrayBuffer;
+ this.setStaticIndexBuffer = setStaticIndexBuffer;
+ this.setDynamicArrayBuffer = setDynamicArrayBuffer;
+ this.setDynamicIndexBuffer = setDynamicIndexBuffer;
+
+ this.drawTriangles = drawTriangles;
+ this.drawLines = drawLines;
+ this.drawLineStrip = drawLineStrip;
+ this.drawPoints = drawPoints;
+ this.drawTriangleElements = drawTriangleElements;
+ this.drawLineElements = drawLineElements;
+
+ this.bindArrayBuffer = bindArrayBuffer;
+ this.bindElementArrayBuffer = bindElementArrayBuffer;
+
+ this.enableAttribute = enableAttribute;
+ this.disableAttributes = disableAttributes;
+ this.getAttribLocation = getAttribLocation;
+ this.setFloatAttribute = setFloatAttribute;
+
+ this.getUniformLocation= getUniformLocation;
+
+ this.uniform1i = uniform1i;
+ this.uniform1f = uniform1f;
+ this.uniform2f = uniform2f;
+ this.uniform3f = uniform3f;
+ this.uniform4f = uniform4f;
+ this.uniform1iv = uniform1iv;
+ this.uniform2iv = uniform2iv;
+ this.uniform3iv = uniform3iv;
+ this.uniform1fv = uniform1fv;
+ this.uniform2fv = uniform2fv;
+ this.uniform3fv = uniform3fv;
+ this.uniform4fv = uniform4fv;
+ this.uniformMatrix3fv = uniformMatrix3fv;
+ this.uniformMatrix4fv = uniformMatrix4fv;
+
+ this.useProgram = useProgram;
+ this.compileShader = compileShader;
+
+ this.setFaceCulling = setFaceCulling;
+ this.setMaterialFaces = setMaterialFaces;
+ this.setPolygonOffset = setPolygonOffset;
+ this.setBlending = setBlending;
+ this.setDepthTest = setDepthTest;
+ this.setDepthWrite = setDepthWrite;
+
+ this.setTexture = setTexture;
+ this.setCubeTexture = setCubeTexture;
+ this.updateRenderTargetMipmap = updateRenderTargetMipmap;
+ this.setCubeTextureDynamic = setCubeTextureDynamic;
+
+ this.paramThreeToGL = paramThreeToGL;
+ this.setLineWidth = setLineWidth;
+ this.resetState = resetState;
+
};
+ | false |
Other | mrdoob | three.js | 3595365f6b45995aa442d1d3039c92e9a91dae5a.json | add Plane.intersectLine with unit tests. | src/math/Plane.js | @@ -112,6 +112,40 @@ THREE.Plane.prototype = {
},
+ intersectLine: function ( startPoint, endPoint, optionalTarget ) {
+
+ var result = optionalTarget || new THREE.Vector3();
+
+ var direction = THREE.Plane.__v1.sub( endPoint, startPoint );
+
+ var denominator = this.normal.dot( direction );
+
+ if ( denominator == 0 ) {
+
+ // line is coplanar, return origin
+ if( this.distanceToPoint( startPoint ) == 0 ) {
+
+ return result.copy( startPoint );
+
+ }
+
+ // Unsure if this is the correct method to handle this case.
+ return undefined;
+
+ }
+
+ var t = - ( startPoint.dot( this.normal ) + this.constant ) / denominator;
+
+ if( t < 0 || t > 1 ) {
+
+ return undefined;
+
+ }
+
+ return result.copy( direction ).multiplyScalar( t ).addSelf( startPoint );
+
+ },
+
coplanarPoint: function ( optionalTarget ) {
var result = optionalTarget || new THREE.Vector3(); | true |
Other | mrdoob | three.js | 3595365f6b45995aa442d1d3039c92e9a91dae5a.json | add Plane.intersectLine with unit tests. | test/unit/math/Plane.js | @@ -115,6 +115,31 @@ test( "distanceToSphere", function() {
ok( a.distanceToSphere( b ) === -1, "Passed!" );
});
+test( "isInterestionLine/intersectLine", function() {
+ var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
+
+ ok( a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
+ ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
+
+ a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -3 );
+
+ ok( a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
+ ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ).equals( new THREE.Vector3( 3, 0, 0 ) ), "Passed!" );
+
+
+ a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -11 );
+
+ ok( ! a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
+ ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ) === undefined, "Passed!" );
+
+ a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 11 );
+
+ ok( ! a.isIntersectionLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
+ ok( a.intersectLine( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) ) === undefined, "Passed!" );
+
+});
+
+
test( "projectPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
| true |
Other | mrdoob | three.js | 4392f0ccfd03ed489eba7542e6529278d56321ec.json | update the clock documentation | docs/api/core/Clock.html | @@ -22,26 +22,45 @@ <h3>[name]( [page:Boolean autoStart] )</h3>
<h2>Properties</h2>
<h3>.[page:Boolean autoStart]</h3>
+ <div>
+ If set, starts the clock automatically when the first update is called.
+ </div>
<h3>.[page:Float startTime]</h3>
+ <div>
+ When the clock is running, It holds the starttime of the clock. <br />
+ This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
+ </div>
+
<h3>.[page:Float oldTime]</h3>
+ <div>
+ When the clock is running, It holds the previous time from a update.<br />
+ This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
+ </div>
<h3>.[page:Float elapsedTime]</h3>
+ <div>
+ When the clock is running, It holds the time elapsed btween the start of the clock to the previous update.<br />
+ This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
+ </div>
<h3>.[page:Boolean running]</h3>
+ <div>
+ This property keeps track whether the clock is running or not.
+ </div>
<h2>Methods</h2>
<h3>.start()</h3>
<div>
- Start clock.
+ Starts clock.
</div>
<h3>.stop()</h3>
<div>
- Stop clock.
+ Stops clock.
</div>
<h3>.getElapsedTime() [page:Float]</h3> | false |
Other | mrdoob | three.js | baa928e5814f9170346d14088e711a26d1376b68.json | add source for THREE.extend method. | src/Three.js | @@ -45,7 +45,7 @@ String.prototype.trim = String.prototype.trim || function () {
};
-
+// based on http://stackoverflow.com/a/12317051
THREE.extend = function ( target, other ) {
target = target || {};
@@ -65,7 +65,7 @@ THREE.extend = function ( target, other ) {
}
return target;
-
+
};
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | false |
Other | mrdoob | three.js | 2ff8f9eca1653688a72ff9ff97492463515d742f.json | update the docs for THREE.Camera | docs/api/cameras/Camera.html | @@ -1,43 +1,52 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <script src="../../list.js"></script>
- <script src="../../page.js"></script>
- <link type="text/css" rel="stylesheet" href="../../page.css" />
- </head>
- <body>
- [page:Object3D] →
-
- <h1>[name]</h1>
-
- <div class="desc">Abstract base class for cameras.</div>
-
-
- <h2>Constructor</h2>
-
- <h3>[name]()</h3>
-
-
- <h2>Properties</h2>
-
- <h3>.[page:Matrix4 matrixWorldInverse]</h3>
-
- <h3>.[page:Matrix4 projectionMatrix]</h3>
-
- <h3>.[page:Matrix4 projectionMatrixInverse]</h3>
-
-
- <h2>Methods</h2>
-
- <h3>.lookAt( [page:Vector3 vector] )</h3>
- <div>
- vector β point to look at<br />
- </div>
-
-
- <h2>Source</h2>
-
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
-</html>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <script src="../../list.js"></script>
+ <script src="../../page.js"></script>
+ <link type="text/css" rel="stylesheet" href="../../page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <div class="desc">Abstract base class for cameras. This class should always be inherited when you build a new camera.</div>
+
+
+ <h2>Constructor</h2>
+
+ <h3>[name]()</h3>
+ <div>
+ This constructor sets following properties to the correct type: matrixWorldInverse, projectionMatrix and projectionMatrixInverse.
+
+ </div>
+
+
+ <h2>Properties</h2>
+
+ <h3>.[page:Matrix4 matrixWorldInverse]</h3>
+ <div>This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera.</div>
+
+ <h3>.[page:Matrix4 projectionMatrix]</h3>
+ <div>This is the matrix which contains the projection.</div>
+
+ <h3>.[page:Matrix4 projectionMatrixInverse]</h3>
+ <div>This is the inverse of projectionMatrix.</div>
+
+
+ <h2>Methods</h2>
+
+ <h3>.lookAt( [page:Vector3 vector] )</h3>
+ <div>
+ vector β point to look at<br />
+ <br />
+ This make the camera look at the vector position in local space.
+ </div>
+
+
+ <h2>Source</h2>
+
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </body>
+</html>
| false |
Other | mrdoob | three.js | 19d815f5898206549440f0186bf5758397d09a3d.json | Add missing LoadingMonitor in the source | build/three.js | @@ -8134,6 +8134,42 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texturePath
callback( geometry );
};
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.LoadingMonitor = function () {
+
+ THREE.EventTarget.call( this );
+
+ var scope = this;
+
+ var loaded = 0;
+ var total = 0;
+
+ var onLoad = function ( event ) {
+
+ loaded ++;
+
+ scope.dispatchEvent( { type: 'progress', loaded: loaded, total: total } );
+
+ if ( loaded === total ) {
+
+ scope.dispatchEvent( { type: 'load' } );
+
+ }
+
+ };
+
+ this.add = function ( loader ) {
+
+ total ++;
+
+ loader.addEventListener( 'load', onLoad, false );
+
+ };
+
+};
/**
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
| true |
Other | mrdoob | three.js | 19d815f5898206549440f0186bf5758397d09a3d.json | Add missing LoadingMonitor in the source | build/three.min.js | @@ -6,7 +6,7 @@ function(a){clearTimeout(a)}})();THREE.FrontSide=0;THREE.BackSide=1;THREE.Double
THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.UVMapping=function(){};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};
THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012;THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.UnsignedShort4444Type=1016;
THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004;THREE.Clock=function(a){this.autoStart=a!==void 0?a:true;this.elapsedTime=this.oldTime=this.startTime=0;this.running=false};
-THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=true};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=false};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime=this.elapsedTime+this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime=this.elapsedTime+a}return a};
+THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=true};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=false};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime=this.elapsedTime+this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.0010*(b-this.oldTime);this.oldTime=b;this.elapsedTime=this.elapsedTime+a}return a};
THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,e;if(c===0)this.r=this.g=this.b=0;else{d=Math.floor(a*6);f=a*6-d;a=c*(1-b);e=c*(1-b*f);b=c*(1-b*(1-f));if(d===0){this.r=c;this.g=b;this.b=a}else if(d===1){this.r=e;this.g=c;this.b=a}else if(d===2){this.r=a;this.g=c;this.b=b}else if(d===3){this.r=a;this.g=e;this.b=c}else if(d===4){this.r=b;this.g=a;this.b=c}else if(d===5){this.r=c;this.g=a;this.b=e}}return this},setHex:function(a){a=
@@ -29,7 +29,7 @@ THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=
this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;this.w=this.w-a.w;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a;this.w=this.w/a}else{this.z=this.y=this.x=0;this.w=1}return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;this.w=this.w+(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*
Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y=a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(Math.abs(d-g)<0.01&&Math.abs(e-c)<0.01&&Math.abs(i-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(e+c)<0.1&&Math.abs(i+b)<0.1&&Math.abs(f+h+j-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;e=
-(e+c)/4;i=(i+b)/4;if(f>h&&f>j)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(h>j)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=i/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=e/d;c=i/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.001&&(a=1);this.x=(b-i)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
+(e+c)/4;i=(i+b)/4;if(f>h&&f>j)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(h>j)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=i/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=e/d;c=i/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-i)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*h;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*f;l[4]=b*e;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*j;return this},
transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,g,h,i,j,l,n,m,q,p,o){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,h||0,i||0,j||0,l!==void 0?l:1,n||0,m||0,q||0,p||0,o!==void 0?o:1)};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,h,i,j,l,n,m,q,p,o){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=f;r[5]=e;r[9]=g;r[13]=h;r[2]=i;r[6]=j;r[10]=l;r[14]=n;r[3]=m;r[7]=q;r[11]=p;r[15]=o;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
@@ -94,9 +94,9 @@ c*d*h-e*g*f;this.w=c*d*f+e*g*h}else if(b==="ZXY"){this.x=e*d*f-c*g*h;this.y=c*g*
d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+e+b;if(j>0){c=0.5/Math.sqrt(j+1);this.w=0.25/c;this.x=(i-g)*c;this.y=(d-h)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(i-g)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+h)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-h)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(g+i)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x=
(d+h)/c;this.y=(g+i)/c;this.z=0.25*c}return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x=this.x*-1;this.y=this.y*-1;this.z=this.z*-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y=
this.y*a;this.z=this.z*a;this.w=this.w*a}return this},multiply:function(a,b){var c=a.x,d=a.y,f=a.z,e=a.w,g=b.x,h=b.y,i=b.z,j=b.w;this.x=c*j+d*i-f*h+e*g;this.y=-c*i+d*j+f*g+e*h;this.z=c*h-d*g+f*j+e*i;this.w=-c*g-d*h-f*i+e*j;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=
-this.y,h=this.z,i=this.w,j=i*c+g*f-h*d,l=i*d+h*c-e*f,n=i*f+e*d-g*c,c=-e*c-g*d-h*f;b.x=j*i+c*-e+l*-h-n*-g;b.y=l*i+c*-g+n*-e-j*-h;b.z=n*i+c*-h+j*-g-l*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var h=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.001){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x);this.y=0.5*
+this.y,h=this.z,i=this.w,j=i*c+g*f-h*d,l=i*d+h*c-e*f,n=i*f+e*d-g*c,c=-e*c-g*d-h*f;b.x=j*i+c*-e+l*-h-n*-g;b.y=l*i+c*-g+n*-e-j*-h;b.z=n*i+c*-h+j*-g-l*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var h=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x);this.y=0.5*
(d+this.y);this.z=0.5*(f+this.z);return this}g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=e*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+this.y*h;this.z=f*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};
+THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};
THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
@@ -170,7 +170,8 @@ THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,
16;l=q&32;p=q&64;q=q&128;if(j){o=new THREE.Face4;o.a=w[c++];o.b=w[c++];o.c=w[c++];o.d=w[c++];j=4}else{o=new THREE.Face3;o.a=w[c++];o.b=w[c++];o.c=w[c++];j=3}if(h){h=w[c++];o.materialIndex=h}h=d.faces.length;if(e)for(e=0;e<v;e++){r=a.uvs[e];m=w[c++];u=r[m*2];m=r[m*2+1];d.faceUvs[e][h]=new THREE.UV(u,m)}if(g)for(e=0;e<v;e++){r=a.uvs[e];t=[];for(g=0;g<j;g++){m=w[c++];u=r[m*2];m=r[m*2+1];t[g]=new THREE.UV(u,m)}d.faceVertexUvs[e][h]=t}if(n){n=w[c++]*3;g=new THREE.Vector3;g.x=s[n++];g.y=s[n++];g.z=s[n];
o.normal=g}if(l)for(e=0;e<j;e++){n=w[c++]*3;g=new THREE.Vector3;g.x=s[n++];g.y=s[n++];g.z=s[n];o.vertexNormals.push(g)}if(p){l=w[c++];l=new THREE.Color(B[l]);o.color=l}if(q)for(e=0;e<j;e++){l=w[c++];l=new THREE.Color(B[l]);o.vertexColors.push(l)}d.faces.push(o)}if(a.skinWeights){c=0;for(i=a.skinWeights.length;c<i;c=c+2){w=a.skinWeights[c];s=a.skinWeights[c+1];d.skinWeights.push(new THREE.Vector4(w,s,0,0))}}if(a.skinIndices){c=0;for(i=a.skinIndices.length;c<i;c=c+2){w=a.skinIndices[c];s=a.skinIndices[c+
1];d.skinIndices.push(new THREE.Vector4(w,s,0,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets!==void 0){c=0;for(i=a.morphTargets.length;c<i;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];B=d.morphTargets[c].vertices;v=a.morphTargets[c].vertices;w=0;for(s=v.length;w<s;w=w+3){q=new THREE.Vector3;q.x=v[w]*f;q.y=v[w+1]*f;q.z=v[w+2]*f;B.push(q)}}}if(a.morphColors!==void 0){c=0;for(i=a.morphColors.length;c<i;c++){d.morphColors[c]={};
-d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];s=d.morphColors[c].colors;B=a.morphColors[c].colors;f=0;for(w=B.length;f<w;f=f+3){v=new THREE.Color(16755200);v.setRGB(B[f],B[f+1],B[f+2]);s.push(v)}}}d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
+d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];s=d.morphColors[c].colors;B=a.morphColors[c].colors;f=0;for(w=B.length;f<w;f=f+3){v=new THREE.Color(16755200);v.setRGB(B[f],B[f+1],B[f+2]);s.push(v)}}}d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};
+THREE.LoadingMonitor=function(){THREE.EventTarget.call(this);var a=this,b=0,c=0,d=function(){b++;a.dispatchEvent({type:"progress",loaded:b,total:c});b===c&&a.dispatchEvent({type:"load"})};this.add=function(a){c++;a.addEventListener("load",d,false)}};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
THREE.GeometryLoader.prototype={constructor:THREE.GeometryLoader,load:function(a){var b=this,c=null;if(b.path===null){var d=a.split("/");d.pop();b.path=d.length<1?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),f):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},false);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);d.open("GET",
a,true);d.send(null);var f=new THREE.LoadingMonitor;f.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});f.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;if(a.materials){d.materials=[];for(var e=0;e<a.materials.length;++e){var g=a.materials[e],h=function(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a},i=function(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))},j=function(a,d,f,e,g,j){a[d]=new THREE.Texture;a[d].sourceFile=
f;if(e){a[d].repeat.set(e[0],e[1]);if(e[0]!==1)a[d].wrapS=THREE.RepeatWrapping;if(e[1]!==1)a[d].wrapT=THREE.RepeatWrapping}g&&a[d].offset.set(g[0],g[1]);if(j){e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(e[j[0]]!==void 0)a[d].wrapS=e[j[0]];if(e[j[1]]!==void 0)a[d].wrapT=e[j[1]]}var l=a[d],a=new THREE.ImageLoader;a.addEventListener("load",function(a){a=a.content;if(!h(a.width)||!h(a.height)){var b=i(a.width),c=i(a.height);l.image=document.createElement("canvas");l.image.width=
@@ -600,7 +601,7 @@ this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);t
THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],f,e,g,h,i,j;f=(a.length-1)*b;e=Math.floor(f);f=f-e;c[0]=e===0?e:e-1;c[1]=e;c[2]=e>a.length-2?e:e+1;c[3]=e>a.length-3?e:e+2;e=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=f*f;g=f*c;d[0]=this.interpolate(e[0],h[0],i[0],j[0],f,c,g);d[1]=this.interpolate(e[1],h[1],i[1],j[1],f,c,g);d[2]=this.interpolate(e[2],h[2],i[2],j[2],f,c,g);return d};
THREE.Animation.prototype.interpolate=function(a,b,c,d,f,e,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[0]};
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
-THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var e=c[f],g=this.getNextKeyWith(e,a,0);g&&g.apply(e)}d.matrixAutoUpdate=
+THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var e=c[f],g=this.getNextKeyWith(e,a,0);g&&g.apply(e)}d.matrixAutoUpdate=
false;this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}};
THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,f,e;for(c=0;c<d;c++){f=this.hierarchy[c];e=this.data.hierarchy[c];f.useQuaternion=true;if(e.animationCache===void 0){e.animationCache={};e.animationCache.prevKey=null;e.animationCache.nextKey=null;e.animationCache.originalMatrix=f instanceof THREE.Bone?
f.skinMatrix:f.matrix}f=this.data.hierarchy[c].keys;if(f.length){e.animationCache.prevKey=f[0];e.animationCache.nextKey=f[1];this.startTime=Math.min(f[0].time,this.startTime);this.endTime=Math.max(f[f.length-1].time,this.endTime)}}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
@@ -619,7 +620,7 @@ THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;thi
THREE.CombinedCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);var c=2*Math.atan(b/(a*2))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
-THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.lookVertical=true;this.autoForward=false;this.activeLook=true;this.heightSpeed=false;this.heightCoef=1;this.heightMin=0;this.heightMax=1;this.constrainVertical=false;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=
+THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.lookVertical=true;this.autoForward=false;this.activeLook=true;this.heightSpeed=false;this.heightCoef=1;this.heightMin=0;this.heightMax=1;this.constrainVertical=false;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=
this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=false;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===document){this.viewHalfX=window.innerWidth/2;this.viewHalfY=window.innerHeight/2}else{this.viewHalfX=this.domElement.offsetWidth/2;this.viewHalfY=this.domElement.offsetHeight/2}};this.onMouseDown=function(a){this.domElement!==
document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=true;break;case 2:this.moveBackward=true}this.mouseDragOn=true};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=false;break;case 2:this.moveBackward=false}this.mouseDragOn=false};this.onMouseMove=function(a){if(this.domElement===document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-
this.viewHalfY}else{this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX;this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY}};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=true;break;case 37:case 65:this.moveLeft=true;break;case 40:case 83:this.moveBackward=true;break;case 39:case 68:this.moveRight=true;break;case 82:this.moveUp=true;break;case 70:this.moveDown=true;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=
@@ -630,14 +631,14 @@ this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.
c(this,this.onMouseUp),false);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),false);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),false);this.handleResize()};
THREE.PathControls=function(a,b){function c(a){return(a=a*2)<1?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,t=0;f=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<r-1;f++){t=d*h.chunks[f]/h.total;b.keys[f]={time:t,pos:g[f]}}e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,false)}function e(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++){d=c/(a.points.length*b);d=a.getPoint(d);e.vertices[c]=new THREE.Vector3(d.x,d.y,d.z)}return e}this.object=a;this.domElement=b!==void 0?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=true;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;
-this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=this.lookVertical=true;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;var g=Math.PI*2,h=Math.PI/180;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===
+this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=true;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;var g=Math.PI*2,h=Math.PI/180;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===
document){this.viewHalfX=window.innerWidth/2;this.viewHalfY=window.innerHeight/2}else{this.viewHalfX=this.domElement.offsetWidth/2;this.viewHalfY=this.domElement.offsetHeight/2}};this.update=function(a){var b;if(this.lookHorizontal)this.lon=this.lon+this.mouseX*this.lookSpeed*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*this.lookSpeed*a;this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%g;this.phi=
a>=0?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};
this.onMouseMove=function(a){if(this.domElement===document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-this.viewHalfY}else{this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX;this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY}};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),
b=new THREE.MeshLambertMaterial({color:65280}),c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else{this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.target);this.animationParent.add(this.object)}if(this.createDebugPath){var a=
this.debugPath,b=this.spline,g=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),q=0;q<b.points.length;q++){c=new THREE.Mesh(g,h);c.position.copy(b.points[q]);a.add(c)}}this.domElement.addEventListener("mousemove",d(this,
this.onMouseMove),false)};this.handleResize()};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=b!==void 0?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=false;this.object.useQuaternion=true;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=
+THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=b!==void 0?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=false;this.object.useQuaternion=true;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=
new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=
1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=
0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -759,7 +760,7 @@ b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b
"color");m.scale=b.getUniformLocation(l,"scale");m.rotation=b.getUniformLocation(l,"rotation");m.screenPosition=b.getUniformLocation(l,"screenPosition");q=false};this.render=function(a,d,f,t){var a=a.__webglFlares,u=a.length;if(u){var w=new THREE.Vector3,s=t/f,B=f*0.5,v=t*0.5,A=16/t,E=new THREE.Vector2(A*s,A),z=new THREE.Vector3(1,1,0),M=new THREE.Vector2(1,1),D=m,A=n;b.useProgram(l);if(!q){b.enableVertexAttribArray(n.vertex);b.enableVertexAttribArray(n.uv);q=true}b.uniform1i(D.occlusionMap,0);b.uniform1i(D.map,
1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(A.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(A.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var G,H,O,F,J;for(G=0;G<u;G++){A=16/t;E.set(A*s,A);F=a[G];w.set(F.matrixWorld.elements[12],F.matrixWorld.elements[13],F.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(w);d.projectionMatrix.multiplyVector3(w);z.copy(w);M.x=z.x*B+B;M.y=z.y*v+v;if(j||M.x>0&&M.x<f&&M.y>0&&
M.y<t){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,M.x-8,M.y-8,16,16,0);b.uniform1i(D.renderType,0);b.uniform2f(D.scale,E.x,E.y);b.uniform3f(D.screenPosition,z.x,z.y,z.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,M.x-8,M.y-8,16,16,0);b.uniform1i(D.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);
-b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);F.positionScreen.copy(z);F.customUpdateCallback?F.customUpdateCallback(F):F.updateLensFlares();b.uniform1i(D.renderType,2);b.enable(b.BLEND);H=0;for(O=F.lensFlares.length;H<O;H++){J=F.lensFlares[H];if(J.opacity>0.001&&J.scale>0.001){z.x=J.x;z.y=J.y;z.z=J.z;A=J.size*J.scale/t;E.x=A*s;E.y=A;b.uniform3f(D.screenPosition,z.x,z.y,z.z);b.uniform2f(D.scale,E.x,E.y);b.uniform1f(D.rotation,J.rotation);b.uniform1f(D.opacity,J.opacity);
+b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);F.positionScreen.copy(z);F.customUpdateCallback?F.customUpdateCallback(F):F.updateLensFlares();b.uniform1i(D.renderType,2);b.enable(b.BLEND);H=0;for(O=F.lensFlares.length;H<O;H++){J=F.lensFlares[H];if(J.opacity>0.0010&&J.scale>0.0010){z.x=J.x;z.y=J.y;z.z=J.z;A=J.size*J.scale/t;E.x=A*s;E.y=A;b.uniform3f(D.screenPosition,z.x,z.y,z.z);b.uniform2f(D.scale,E.x,E.y);b.uniform1f(D.rotation,J.rotation);b.uniform1f(D.opacity,J.opacity);
b.uniform3f(D.color,J.color.r,J.color.g,J.color.b);c.setBlending(J.blending,J.blendEquation,J.blendSrc,J.blendDst);c.setTexture(J.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
THREE.ShadowMapPlugin=function(){var a,b,c,d,f,e,g=new THREE.Frustum,h=new THREE.Matrix4,i=new THREE.Vector3,j=new THREE.Vector3;this.init=function(g){a=g.context;b=g;var g=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(g.uniforms);c=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,
vertexShader:g.vertexShader,uniforms:h,skinning:true});e=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true,skinning:true});c._shadowPass=true;d._shadowPass=true;f._shadowPass=true;e._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(l,n){var m,q,p,o,r,t,u,w,s,B=[];o=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFrontFaces? | true |
Other | mrdoob | three.js | 19d815f5898206549440f0186bf5758397d09a3d.json | Add missing LoadingMonitor in the source | utils/includes/common.json | @@ -35,6 +35,7 @@
"../src/loaders/BinaryLoader.js",
"../src/loaders/ImageLoader.js",
"../src/loaders/JSONLoader.js",
+ "../src/loaders/LoadingMonitor.js",
"../src/loaders/GeometryLoader.js",
"../src/loaders/SceneLoader.js",
"../src/loaders/TextureLoader.js", | true |
Other | mrdoob | three.js | 67fdeb97b935925df82b3a265ff4d383bf981337.json | avoid garbage collector as all costs per @gero3 | src/core/Box2.js | @@ -63,7 +63,7 @@ THREE.Box2.prototype = {
setFromCenterAndSize: function ( center, size ) {
- var halfSize = new THREE.Vector2().copy( size ).multiplyScalar( 0.5 );
+ var halfSize = THREE.Box2.__v1.copy( size ).multiplyScalar( 0.5 );
this.min.copy( center ).subSelf( halfSize );
this.max.copy( center ).addSelf( halfSize );
@@ -217,4 +217,6 @@ THREE.Box2.prototype = {
return this;
}
-};
\ No newline at end of file
+};
+
+THREE.Box2.__v1 = new THREE.Vector2();
\ No newline at end of file | true |
Other | mrdoob | three.js | 67fdeb97b935925df82b3a265ff4d383bf981337.json | avoid garbage collector as all costs per @gero3 | src/core/Box3.js | @@ -70,7 +70,7 @@ THREE.Box3.prototype = {
setFromCenterAndSize: function ( center, size ) {
- var halfSize = new THREE.Vector3().copy( size ).multiplyScalar( 0.5 );
+ var halfSize = THREE.Box3.__v1.copy( size ).multiplyScalar( 0.5 );
this.min.copy( center ).subSelf( halfSize );
this.max.copy( center ).addSelf( halfSize );
@@ -230,4 +230,6 @@ THREE.Box3.prototype = {
return this;
}
-};
\ No newline at end of file
+};
+
+THREE.Box3.__v1 = new THREE.Vector3();
\ No newline at end of file | true |
Other | mrdoob | three.js | b5786bbe06f2299a806f91aa5d66c3a25e21f5c2.json | add Box2 based on Box3 paradigm. | src/core/Box2.js | @@ -0,0 +1,220 @@
+/**
+ * @author bhouston / http://exocortex.com
+ */
+
+THREE.Box2 = function ( min, max ) {
+
+ if( ! min && ! max ) {
+ this.min = new THREE.Vector2();
+ this.max = new THREE.Vector2();
+ this.makeEmpty();
+ }
+ else {
+ this.min = min || new THREE.Vector2();
+ this.max = max || new THREE.Vector2().copy( this.min ); // This is done on purpose so you can make a box using a single point and then expand it.
+ }
+};
+
+THREE.Box2.prototype = {
+
+ constructor: THREE.Box2,
+
+ set: function ( min, max ) {
+
+ this.min = min;
+ this.max = max;
+
+ return this;
+ },
+
+ setFromPoints: function ( points ) {
+
+ if( points.length > 0 ) {
+
+ var p = points[0];
+ this.min.copy( p );
+ this.max.copy( p );
+
+ for( var i = 1, numPoints = points.length; i < numPoints; i ++ ) {
+
+ p = points[ v ];
+
+ if ( p.x < this.min.x ) {
+ this.min.x = p.x;
+ }
+ else if ( p.x > this.max.x ) {
+ this.max.x = p.x;
+ }
+
+ if ( p.y < this.min.y ) {
+ this.min.y = p.y;
+ }
+ else if ( p.y > this.max.y ) {
+ this.max.y = p.y;
+ }
+ }
+ }
+ else {
+ this.makeEmpty();
+ }
+
+ return this;
+ },
+
+ setFromCenterAndSize: function ( center, size ) {
+
+ var halfSize = new THREE.Vector2().copy( size ).multiplyScalar( 0.5 );
+ this.min.copy( center ).subSelf( halfSize );
+ this.max.copy( center ).addSelf( halfSize );
+
+ return box;
+ },
+
+ copy: function ( box ) {
+
+ this.min.copy( box.min );
+ this.max.copy( box.max );
+
+ return this;
+ },
+
+ makeEmpty: function () {
+
+ this.min.x = this.min.y = Number.MAX_VALUE;
+ this.max.x = this.max.y = -Number.MAX_VALUE;
+
+ return this;
+ },
+
+ empty: function () {
+
+ // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
+ return
+ ( this.max.x < this.min.x ) ||
+ ( this.max.y < this.min.y );
+ },
+
+ volume: function () {
+
+ return
+ ( this.max.x - this.min.x ) *
+ ( this.max.y - this.min.y );
+ },
+
+ center: function () {
+
+ return new THREE.Vector2().add( this.min, this.max ).multiplyScalar( 0.5 );
+ },
+
+ size: function () {
+
+ return new THREE.Vector2().sub( this.max, this.min );
+ },
+
+ expandByPoint: function ( point ) {
+
+ this.min.minSelf( point );
+ this.max.maxSelf( point );
+
+ return this;
+ },
+
+ expandByVector: function ( vector ) {
+
+ this.min.subSelf( vector );
+ this.max.addSelf( vector );
+
+ return this;
+ },
+
+ expandByScalar: function ( scalar ) {
+
+ this.min.addScalar( -scalar );
+ this.max.addScalar( scalar );
+
+ return this;
+ },
+
+ containsPoint: function ( point ) {
+ if(
+ ( this.min.x <= point.x ) && ( point.x <= this.max.x ) &&
+ ( this.min.y <= point.y ) && ( point.y <= this.max.y )
+ ) {
+ return true;
+ }
+ return false;
+ },
+
+ containsBox: function ( box ) {
+ if(
+ ( this.min.x <= box.min.x ) && ( box.max.x <= this.max.x ) &&
+ ( this.min.y <= box.min.y ) && ( box.max.y <= this.max.y )
+ ) {
+ return true;
+ }
+ return false;
+ },
+
+ isIntersection: function ( box ) {
+ // using 6 splitting planes to rule out intersections.
+ if(
+ ( this.max.x < box.min.x ) || ( box.min.x > this.max.x ) ||
+ ( this.max.y < box.min.y ) || ( box.min.y > this.max.y )
+ ) {
+ return false;
+ }
+ return true;
+ },
+
+ getParameter: function ( point ) {
+ // This can potentially have a divide by zero if the box
+ // has a size dimension of 0.
+ return new THREE.Vector2(
+ ( point.x - this.min.x ) / ( this.max.x - this.min.x ),
+ ( point.y - this.min.y ) / ( this.max.y - this.min.y )
+ );
+ },
+
+ clampPoint: function ( point ) {
+
+ return new THREE.Vector2().copy( point ).maxSelf( this.min ).minSelf( this.max );
+ },
+
+ distanceToPoint: function ( point ) {
+
+ return this.clampPoint( point ).subSelf( point ).length();
+ },
+
+ intersect: function ( box ) {
+
+ this.min.maxSelf( box.min );
+ this.max.minSelf( box.max );
+
+ return this;
+ },
+
+ union: function ( box ) {
+
+ this.min.minSelf( box.min );
+ this.max.maxSelf( box.max );
+
+ return this;
+ },
+
+ translate: function ( offset ) {
+
+ this.min.addSelf( offset );
+ this.max.addSelf( offset );
+
+ return this;
+ },
+
+ scale: function ( factor ) {
+
+ var sizeDeltaHalf = this.size().multiplyScalar( ( 1 - factor ) * 0.5 );
+ this.expandByVector( sizeDeltaHalf );
+
+ return this;
+ }
+
+};
\ No newline at end of file | true |
Other | mrdoob | three.js | b5786bbe06f2299a806f91aa5d66c3a25e21f5c2.json | add Box2 based on Box3 paradigm. | utils/includes/common.json | @@ -5,6 +5,7 @@
"../src/core/Vector2.js",
"../src/core/Vector3.js",
"../src/core/Vector4.js",
+ "../src/core/Box2.js",
"../src/core/Box3.js",
"../src/core/Matrix3.js",
"../src/core/Matrix4.js", | true |
Other | mrdoob | three.js | b50a1a520ebd8950a0c3fdb92a015a927d0d69c9.json | remove unnecessary comments. | src/core/Box3.js | @@ -4,7 +4,6 @@
THREE.Box3 = function ( min, max ) {
- // TODO: Is this valid JavaScript to check if the parameters are specified?
if( ! min && ! max ) {
this.min = new THREE.Vector3();
this.max = new THREE.Vector3(); | true |
Other | mrdoob | three.js | b50a1a520ebd8950a0c3fdb92a015a927d0d69c9.json | remove unnecessary comments. | src/core/Plane.js | @@ -30,7 +30,6 @@ THREE.Plane.prototype = {
},
setFromNormalAndCoplanarPoint: function ( normal, point ) {
- // NOTE: This function doens't support optional parameters like the constructor.
this.normal = normal;
this.constant = - point.dot( normal );
@@ -39,7 +38,6 @@ THREE.Plane.prototype = {
},
setFromCoplanarPoints: function ( a, b, c ) {
- // NOTE: This function doens't support optional parameters like the constructor.
var normal = new THREE.Vector3().sub( b, a ).cross(
new THREE.Vector3().sub( c, a ) );
@@ -60,7 +58,6 @@ THREE.Plane.prototype = {
flip: function () {
- // Note: can also be flipped by inverting constant, but I like constant to stay positive generally.
this.normal.negate();
return this;
@@ -116,7 +113,6 @@ THREE.Plane.prototype = {
translate: function ( offset ) {
- // TODO: test this.
this.constant = - offset.dot( normal );
return this; | true |
Other | mrdoob | three.js | cb2b5cece276091dd253935e698621c3918a8913.json | adopt Sphere.js and Box3.js in Geometry.js. | src/core/Box3.js | @@ -19,7 +19,7 @@
THREE.Box3.fromPoints = function ( points ) {
var boundingBox = new THREE.Box3();
- for( var i = 0; i < points.length; i ++ ) {
+ for( var i = 0, numPoints = points.length; i < numPoints; i ++ ) {
boundingBox.extendByPoint( points[i] );
}
| true |
Other | mrdoob | three.js | cb2b5cece276091dd253935e698621c3918a8913.json | adopt Sphere.js and Box3.js in Geometry.js. | src/core/Geometry.js | @@ -4,6 +4,7 @@
* @author alteredq / http://alteredqualia.com/
* @author mikael emtinger / http://gomo.se/
* @author zz85 / http://www.lab4games.net/zz85/blog
+ * @author Ben Houston / ben@exocortex.com / http://github.com/bhouston
*/
THREE.Geometry = function () {
@@ -576,82 +577,12 @@ THREE.Geometry.prototype = {
computeBoundingBox: function () {
- if ( ! this.boundingBox ) {
-
- this.boundingBox = { min: new THREE.Vector3(), max: new THREE.Vector3() };
-
- }
-
- if ( this.vertices.length > 0 ) {
-
- var position, firstPosition = this.vertices[ 0 ];
-
- this.boundingBox.min.copy( firstPosition );
- this.boundingBox.max.copy( firstPosition );
-
- var min = this.boundingBox.min,
- max = this.boundingBox.max;
-
- for ( var v = 1, vl = this.vertices.length; v < vl; v ++ ) {
-
- position = this.vertices[ v ];
-
- if ( position.x < min.x ) {
-
- min.x = position.x;
-
- } else if ( position.x > max.x ) {
-
- max.x = position.x;
-
- }
-
- if ( position.y < min.y ) {
-
- min.y = position.y;
-
- } else if ( position.y > max.y ) {
-
- max.y = position.y;
-
- }
-
- if ( position.z < min.z ) {
-
- min.z = position.z;
-
- } else if ( position.z > max.z ) {
-
- max.z = position.z;
-
- }
-
- }
-
- } else {
-
- this.boundingBox.min.set( 0, 0, 0 );
- this.boundingBox.max.set( 0, 0, 0 );
-
- }
-
+ this.boundingBox = THREE.Box3.fromPoints( this.vertices );
},
computeBoundingSphere: function () {
- var maxRadiusSq = 0;
-
- if ( this.boundingSphere === null ) this.boundingSphere = { radius: 0 };
-
- for ( var i = 0, l = this.vertices.length; i < l; i ++ ) {
-
- var radiusSq = this.vertices[ i ].lengthSq();
- if ( radiusSq > maxRadiusSq ) maxRadiusSq = radiusSq;
-
- }
-
- this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
-
+ this.boundingSphere = THREE.Sphere.fromCenterAndPoints( new THREE.Vector3(), this.vertices );
},
/* | true |
Other | mrdoob | three.js | cb2b5cece276091dd253935e698621c3918a8913.json | adopt Sphere.js and Box3.js in Geometry.js. | src/core/Sphere.js | @@ -15,6 +15,18 @@
};
+ THREE.Sphere.fromCenterAndPoints = function ( center, points ) {
+ var maxRadiusSq = 0;
+ var delta = new THREE.Vector3().copy( center );
+
+ for ( var i = 0, numPoints = points.length; i < numPoints; i ++ ) {
+ var radiusSq = center.distanceToSquared( points[i] );
+ maxRadiusSq = Math.max( maxRadiusSq, radiusSq );
+ }
+
+ return new THREE.Sphere( center, Math.sqrt( maxRadiusSq ) );
+ };
+
THREE.Sphere.prototype.set = function ( center, radius ) {
this.center = center; | true |
Other | mrdoob | three.js | 4d7b88da36054cb37692be8dddeb03d977b8aeaa.json | use relative path to create the index
This seems to be working so, I'm going to leave it like this | CONTRIBUTING.md | @@ -2,10 +2,10 @@
## 1. Index
-1. [Index](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#2-Index)
-2. [Having a problem](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#2-having-a-problem)
- * [How to report](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#how-to-report)
- * [Migrating problems](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#migrating-problems)
+1. [Index](#2-Index)
+2. [Having a problem](#2-having-a-problem)
+ * [How to report](#how-to-report)
+ * [Migrating problems](#migrating-problems)
## 2. Having a problem
| false |
Other | mrdoob | three.js | db87a042bcb36203a04105f79b99204759026aca.json | add index to contributing | CONTRIBUTING.md | @@ -1,6 +1,13 @@
# CONTRIBUTING TO THREE.JS
-## Having a problem
+## 1. Index
+
+1. [Index](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#2-Index)
+2. [Having a problem](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#2-having-a-problem)
+ * [How to report](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#how-to-report)
+ * [Migrating problems](https://github.com/gero3/three.js/blob/patch-6/CONTRIBUTING.md#migrating-problems)
+
+## 2. Having a problem
We use 2 different systems to have explain problems.
| false |
Other | mrdoob | three.js | 6b3eaa0d354e8e09431c1c5aae8837dd57163811.json | Add deallocation to BufferGeometry. | build/three.js | @@ -6014,6 +6014,13 @@ THREE.BufferGeometry.prototype = {
this.hasTangents = true;
this.tangentsNeedUpdate = true;
+ },
+
+ deallocate: function () {
+
+ var index = THREE.GeometryLibrary.indexOf( this );
+ if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
+
}
}; | true |
Other | mrdoob | three.js | 6b3eaa0d354e8e09431c1c5aae8837dd57163811.json | Add deallocation to BufferGeometry. | build/three.min.js | @@ -6,7 +6,7 @@ function(a){window.clearTimeout(a)}})();THREE.FrontSide=0;THREE.BackSide=1;THREE
THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.UVMapping=function(){};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};
THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012;THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.UnsignedShort4444Type=1016;
THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004;THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};
-THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};
+THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.0010*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};
THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,f;0===c?this.r=this.g=this.b=0:(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),0===d?(this.r=c,this.g=b,this.b=a):1===d?(this.r=f,this.g=c,this.b=a):2===d?(this.r=a,this.g=c,this.b=b):3===d?(this.r=a,this.g=f,this.b=c):4===d?(this.r=b,this.g=a,this.b=c):5===d&&(this.r=c,this.g=a,this.b=f));return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&
@@ -28,7 +28,7 @@ THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=
a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+
Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):
(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(0.01>Math.abs(d-g)&&0.01>Math.abs(f-c)&&0.01>Math.abs(i-b)){if(0.1>Math.abs(d+g)&&0.1>Math.abs(f+c)&&0.1>Math.abs(i+b)&&0.1>Math.abs(e+h+j-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;e>h&&e>j?0.01>e?(b=0,d=c=0.707106781):(b=Math.sqrt(e),c=d/b,d=f/
-b):h>j?0.01>h?(b=0.707106781,c=0,d=0.707106781):(c=Math.sqrt(h),b=d/c,d=i/c):0.01>j?(c=b=0.707106781,d=0):(d=Math.sqrt(j),b=f/d,c=i/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));0.001>Math.abs(a)&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
+b):h>j?0.01>h?(b=0.707106781,c=0,d=0.707106781):(c=Math.sqrt(h),b=d/c,d=i/c):0.01>j?(c=b=0.707106781,d=0):(d=Math.sqrt(j),b=f/d,c=i/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));0.0010>Math.abs(a)&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;0===b&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*e;l[4]=b*f;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*j;return this},
transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,j,l,m,n,p,o,q){this.elements=new Float32Array(16);this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,i||0,j||0,void 0!==l?l:1,m||0,n||0,p||0,o||0,void 0!==q?q:1)};
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,j,l,m,n,p,o,q){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=e;r[5]=f;r[9]=g;r[13]=h;r[2]=i;r[6]=j;r[10]=l;r[14]=m;r[3]=n;r[7]=p;r[11]=o;r[15]=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
@@ -94,9 +94,9 @@ h-f*g*e,this.w=c*d*e+f*g*h):"ZXY"===b?(this.x=f*d*e-c*g*h,this.y=c*g*e+f*d*h,thi
return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+f+b;0<j?(c=0.5/Math.sqrt(j+1),this.w=0.25/c,this.x=(i-g)*c,this.y=(d-h)*c,this.z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this.w=(i-g)/c,this.x=0.25*c,this.y=(a+e)/c,this.z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this.w=(d-h)/c,this.x=(a+e)/c,this.y=0.25*c,this.z=(g+i)/c):(c=2*Math.sqrt(1+b-c-f),this.w=(e-a)/c,this.x=(d+h)/c,this.y=(g+i)/c,this.z=0.25*c);return this},calculateW:function(){this.w=
-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiply:function(a,b){var c=a.x,d=a.y,e=a.z,f=a.w,g=b.x,h=b.y,i=b.z,j=b.w;
this.x=c*j+d*i-e*h+f*g;this.y=-c*i+d*j+e*g+f*h;this.z=c*h-d*g+e*j+f*i;this.w=-c*g-d*h-e*i+f*j;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,l=i*d+h*c-f*e,m=i*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*i+c*-f+l*-h-m*-g;b.y=l*i+c*-g+m*-f-j*-h;
-b.z=m*i+c*-h+j*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;0>g?(this.w=-a.w,this.x=-a.x,this.y=-a.y,this.z=-a.z,g=-g):this.copy(a);if(1<=g)return this.w=f,this.x=c,this.y=d,this.z=e,this;var h=Math.acos(g),i=Math.sqrt(1-g*g);if(0.001>Math.abs(i))return this.w=0.5*(f+this.w),this.x=0.5*(c+this.x),this.y=0.5*(d+this.y),this.z=0.5*(e+this.z),this;g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+
+b.z=m*i+c*-h+j*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;0>g?(this.w=-a.w,this.x=-a.x,this.y=-a.y,this.z=-a.z,g=-g):this.copy(a);if(1<=g)return this.w=f,this.x=c,this.y=d,this.z=e,this;var h=Math.acos(g),i=Math.sqrt(1-g*g);if(0.0010>Math.abs(i))return this.w=0.5*(f+this.w),this.x=0.5*(c+this.x),this.y=0.5*(d+this.y),this.z=0.5*(e+this.z),this;g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+
this.y*h;this.z=e*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var b=Math.acos(e),f=Math.sqrt(1-e*e);if(0.001>Math.abs(f))return c.w=0.5*(a.w+c.w),c.x=0.5*(a.x+c.x),c.y=0.5*(a.y+c.y),c.z=0.5*(a.z+c.z),c;e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var b=Math.acos(e),f=Math.sqrt(1-e*e);if(0.0010>Math.abs(f))return c.w=0.5*(a.w+c.w),c.x=0.5*(a.x+c.x),c.y=0.5*(a.y+c.y),c.z=0.5*(a.z+c.z),c;e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};
THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
@@ -126,7 +126,8 @@ g=this.attributes.position.array,h=this.attributes.normal.array,i,j,l,m,n,p,o=ne
2]+=t.z,h[3*j]+=t.x,h[3*j+1]+=t.y,h[3*j+2]+=t.z,h[3*l]+=t.x,h[3*l+1]+=t.y,h[3*l+2]+=t.z}a=0;for(b=h.length;a<b;a+=3)m=h[a],n=h[a+1],p=h[a+2],c=1/Math.sqrt(m*m+n*n+p*p),h[a]*=c,h[a+1]*=c,h[a+2]*=c;this.normalsNeedUpdate=!0}},computeTangents:function(){function a(a){$.x=d[3*a];$.y=d[3*a+1];$.z=d[3*a+2];Y.copy($);ea=i[a];L.copy(ea);L.subSelf($.multiplyScalar($.dot(ea))).normalize();R.cross(Y,ea);Q=R.dot(j[a]);N=0>Q?-1:1;h[4*a]=L.x;h[4*a+1]=L.y;h[4*a+2]=L.z;h[4*a+3]=N}if(void 0===this.attributes.index||
void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array,d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;if(void 0===this.attributes.tangent){var g=4*f;this.attributes.tangent={itemSize:4,array:new Float32Array(g),numItems:g}}for(var h=this.attributes.tangent.array,
i=[],j=[],g=0;g<f;g++)i[g]=new THREE.Vector3,j[g]=new THREE.Vector3;var l,m,n,p,o,q,r,t,B,u,s,z,A,v,y,f=new THREE.Vector3,g=new THREE.Vector3,C,G,H,J,E,M,K,F=this.offsets;H=0;for(J=F.length;H<J;++H){G=F[H].start;E=F[H].count;var I=F[H].index;C=G;for(G+=E;C<G;C+=3)E=I+b[C],M=I+b[C+1],K=I+b[C+2],l=c[3*E],m=c[3*E+1],n=c[3*E+2],p=c[3*M],o=c[3*M+1],q=c[3*M+2],r=c[3*K],t=c[3*K+1],B=c[3*K+2],u=e[2*E],s=e[2*E+1],z=e[2*M],A=e[2*M+1],v=e[2*K],y=e[2*K+1],p-=l,l=r-l,o-=m,m=t-m,q-=n,n=B-n,z-=u,u=v-u,A-=s,s=y-
-s,y=1/(z*s-u*A),f.set((s*p-A*l)*y,(s*o-A*m)*y,(s*q-A*n)*y),g.set((z*l-u*p)*y,(z*m-u*o)*y,(z*n-u*q)*y),i[E].addSelf(f),i[M].addSelf(f),i[K].addSelf(f),j[E].addSelf(g),j[M].addSelf(g),j[K].addSelf(g)}var L=new THREE.Vector3,R=new THREE.Vector3,$=new THREE.Vector3,Y=new THREE.Vector3,N,ea,Q;H=0;for(J=F.length;H<J;++H){G=F[H].start;E=F[H].count;I=F[H].index;C=G;for(G+=E;C<G;C+=3)E=I+b[C],M=I+b[C+1],K=I+b[C+2],a(E),a(M),a(K)}this.tangentsNeedUpdate=this.hasTangents=!0}}};
+s,y=1/(z*s-u*A),f.set((s*p-A*l)*y,(s*o-A*m)*y,(s*q-A*n)*y),g.set((z*l-u*p)*y,(z*m-u*o)*y,(z*n-u*q)*y),i[E].addSelf(f),i[M].addSelf(f),i[K].addSelf(f),j[E].addSelf(g),j[M].addSelf(g),j[K].addSelf(g)}var L=new THREE.Vector3,R=new THREE.Vector3,$=new THREE.Vector3,Y=new THREE.Vector3,N,ea,Q;H=0;for(J=F.length;H<J;++H){G=F[H].start;E=F[H].count;I=F[H].index;C=G;for(G+=E;C<G;C+=3)E=I+b[C],M=I+b[C+1],K=I+b[C+2],a(E),a(M),a(K)}this.tangentsNeedUpdate=this.hasTangents=!0}},deallocate:function(){var a=THREE.GeometryLibrary.indexOf(this);
+-1!==a&&THREE.GeometryLibrary.splice(a,1)}};
THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,j,l,m,n;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:
f+2;j=this.points[c[0]];l=this.points[c[1]];m=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,l.x,m.x,n.x,g,h,i);d.y=b(j.y,l.y,m.y,n.y,g,h,i);d.z=b(j.z,l.z,m.z,n.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=
a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,l=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];g=Math.ceil(a*c/l.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),
@@ -599,7 +600,7 @@ this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);t
THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,j;e=(a.length-1)*b;f=Math.floor(e);e=e-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],j[2],e,c,g);return d};
THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[0]};
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
-THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=
+THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=
false;this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}};
THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c<d;c++){e=this.hierarchy[c];f=this.data.hierarchy[c];e.useQuaternion=true;if(f.animationCache===void 0){f.animationCache={};f.animationCache.prevKey=null;f.animationCache.nextKey=null;f.animationCache.originalMatrix=e instanceof THREE.Bone?
e.skinMatrix:e.matrix}e=this.data.hierarchy[c].keys;if(e.length){f.animationCache.prevKey=e[0];f.animationCache.nextKey=e[1];this.startTime=Math.min(e[0].time,this.startTime);this.endTime=Math.max(e[e.length-1].time,this.endTime)}}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
@@ -710,7 +711,7 @@ b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b
"color");n.scale=b.getUniformLocation(l,"scale");n.rotation=b.getUniformLocation(l,"rotation");n.screenPosition=b.getUniformLocation(l,"screenPosition");p=false};this.render=function(a,d,e,t){var a=a.__webglFlares,B=a.length;if(B){var u=new THREE.Vector3,s=t/e,z=e*0.5,A=t*0.5,v=16/t,y=new THREE.Vector2(v*s,v),C=new THREE.Vector3(1,1,0),G=new THREE.Vector2(1,1),H=n,v=m;b.useProgram(l);if(!p){b.enableVertexAttribArray(m.vertex);b.enableVertexAttribArray(m.uv);p=true}b.uniform1i(H.occlusionMap,0);b.uniform1i(H.map,
1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(v.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(v.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var J,E,M,K,F;for(J=0;J<B;J++){v=16/t;y.set(v*s,v);K=a[J];u.set(K.matrixWorld.elements[12],K.matrixWorld.elements[13],K.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(u);d.projectionMatrix.multiplyVector3(u);C.copy(u);G.x=C.x*z+z;G.y=C.y*A+A;if(j||G.x>0&&G.x<e&&G.y>0&&
G.y<t){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,G.x-8,G.y-8,16,16,0);b.uniform1i(H.renderType,0);b.uniform2f(H.scale,y.x,y.y);b.uniform3f(H.screenPosition,C.x,C.y,C.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,G.x-8,G.y-8,16,16,0);b.uniform1i(H.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);
-b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);K.positionScreen.copy(C);K.customUpdateCallback?K.customUpdateCallback(K):K.updateLensFlares();b.uniform1i(H.renderType,2);b.enable(b.BLEND);E=0;for(M=K.lensFlares.length;E<M;E++){F=K.lensFlares[E];if(F.opacity>0.001&&F.scale>0.001){C.x=F.x;C.y=F.y;C.z=F.z;v=F.size*F.scale/t;y.x=v*s;y.y=v;b.uniform3f(H.screenPosition,C.x,C.y,C.z);b.uniform2f(H.scale,y.x,y.y);b.uniform1f(H.rotation,F.rotation);b.uniform1f(H.opacity,F.opacity);
+b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);K.positionScreen.copy(C);K.customUpdateCallback?K.customUpdateCallback(K):K.updateLensFlares();b.uniform1i(H.renderType,2);b.enable(b.BLEND);E=0;for(M=K.lensFlares.length;E<M;E++){F=K.lensFlares[E];if(F.opacity>0.0010&&F.scale>0.0010){C.x=F.x;C.y=F.y;C.z=F.z;v=F.size*F.scale/t;y.x=v*s;y.y=v;b.uniform3f(H.screenPosition,C.x,C.y,C.z);b.uniform2f(H.scale,y.x,y.y);b.uniform1f(H.rotation,F.rotation);b.uniform1f(H.opacity,F.opacity);
b.uniform3f(H.color,F.color.r,F.color.g,F.color.b);c.setBlending(F.blending,F.blendEquation,F.blendSrc,F.blendDst);c.setTexture(F.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
THREE.ShadowMapPlugin=function(){var a,b,c,d,e,f,g=new THREE.Frustum,h=new THREE.Matrix4,i=new THREE.Vector3,j=new THREE.Vector3;this.init=function(g){a=g.context;b=g;var g=THREE.ShaderLib.depthRGBA,h=THREE.UniformsUtils.clone(g.uniforms);c=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h});d=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true});e=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,
vertexShader:g.vertexShader,uniforms:h,skinning:true});f=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:h,morphTargets:true,skinning:true});c._shadowPass=true;d._shadowPass=true;e._shadowPass=true;f._shadowPass=true};this.render=function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(l,m){var n,p,o,q,r,t,B,u,s,z=[];q=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);a.frontFace(a.CCW);b.shadowMapCullFrontFaces? | true |
Other | mrdoob | three.js | 6b3eaa0d354e8e09431c1c5aae8837dd57163811.json | Add deallocation to BufferGeometry. | src/core/BufferGeometry.js | @@ -476,6 +476,13 @@ THREE.BufferGeometry.prototype = {
this.hasTangents = true;
this.tangentsNeedUpdate = true;
+ },
+
+ deallocate: function () {
+
+ var index = THREE.GeometryLibrary.indexOf( this );
+ if ( index !== -1 ) THREE.GeometryLibrary.splice( index, 1 );
+
}
}; | true |
Other | mrdoob | three.js | 5816003656333fd317e5b978ee52e2ffbb7d7c26.json | Touch support to TrackballControls. | examples/js/controls/TrackballControls.js | @@ -392,11 +392,60 @@ THREE.TrackballControls = function ( object, domElement ) {
}
+ function touchstart( event ) {
+
+ if ( ! _this.enabled ) return;
+
+ event.preventDefault();
+
+ switch ( event.touches.length ) {
+
+ case 1:
+ _rotateStart = _rotateEnd = _this.getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
+ case 2:
+ _zoomStart = _zoomEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
+ case 3:
+ _panStart = _panEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
+
+ }
+
+ }
+
+ function touchmove( event ) {
+
+ if ( ! _this.enabled ) return;
+
+ event.preventDefault();
+
+ switch ( event.touches.length ) {
+
+ case 1:
+ _rotateEnd = _this.getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
+ case 2:
+ _zoomEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
+ case 3:
+ _panEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
+
+ }
+
+ }
+
this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
this.domElement.addEventListener( 'mousedown', mousedown, false );
- this.domElement.addEventListener( 'DOMMouseScroll', mousewheel, false );
+
this.domElement.addEventListener( 'mousewheel', mousewheel, false );
+ this.domElement.addEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox
+
+ this.domElement.addEventListener( 'touchstart', touchstart, false );
+ this.domElement.addEventListener( 'touchend', touchstart, false );
+ this.domElement.addEventListener( 'touchmove', touchmove, false );
window.addEventListener( 'keydown', keydown, false );
window.addEventListener( 'keyup', keyup, false ); | false |
Other | mrdoob | three.js | e1179f0b9a01b9a019041fb2b6bce84f1f02f92a.json | Move texture images loading code to be static. | examples/js/loaders/MTLLoader.js | @@ -228,7 +228,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
break;
case 'map_kd':
// Diffuse texture map
- params['map'] = this.loadTexture( this.baseUrl + value );
+ params['map'] = THREE.MTLLoader.loadTexture( this.baseUrl + value );
params['map'].wrapS = this.wrap;
params['map'].wrapT = this.wrap;
break;
@@ -256,19 +256,20 @@ THREE.MTLLoader.MaterialCreator.prototype = {
}
this.materials[materialName] = new THREE.MeshPhongMaterial(params);
return this.materials[materialName];
- },
+ }
+};
- loadTexture: function ( url, mapping, onLoad, onError ) {
+THREE.MTLLoader.loadTexture = function ( url, mapping, onLoad, onError ) {
var image = new Image();
var texture = new THREE.Texture( image, mapping );
var loader = new THREE.ImageLoader();
loader.addEventListener( 'load', function ( event ) {
- texture.image = this.ensurePowerOfTwo(event.content);
+ texture.image = THREE.MTLLoader.ensurePowerOfTwo_(event.content);
texture.needsUpdate = true;
if ( onLoad ) onLoad( texture );
- }.bind(this) );
+ } );
loader.addEventListener( 'error', function ( event ) {
if ( onError ) onError( event.message );
@@ -278,34 +279,33 @@ THREE.MTLLoader.MaterialCreator.prototype = {
loader.load( url, image );
return texture;
- },
+ };
- ensurePowerOfTwo: function(image)
+THREE.MTLLoader.ensurePowerOfTwo_ = function (image)
+{
+ if (!THREE.MTLLoader.isPowerOfTwo_(image.width) || !THREE.MTLLoader.isPowerOfTwo_(image.height))
{
- if (!this.isPowerOfTwo(image.width) || !this.isPowerOfTwo(image.height))
- {
- var canvas = document.createElement("canvas");
- canvas.width = this.nextHighestPowerOfTwo(image.width);
- canvas.height = this.nextHighestPowerOfTwo(image.height);
- var ctx = canvas.getContext("2d");
- ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
- return canvas;
- }
- return image;
- },
+ var canvas = document.createElement("canvas");
+ canvas.width = THREE.MTLLoader.nextHighestPowerOfTwo_(image.width);
+ canvas.height = THREE.MTLLoader.nextHighestPowerOfTwo_(image.height);
+ var ctx = canvas.getContext("2d");
+ ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
+ return canvas;
+ }
+ return image;
+};
- isPowerOfTwo: function (x)
- {
- return (x & (x - 1)) == 0;
- },
+THREE.MTLLoader.isPowerOfTwo_ = function (x)
+{
+ return (x & (x - 1)) == 0;
+};
- nextHighestPowerOfTwo: function(x)
- {
- --x;
- for (var i = 1; i < 32; i <<= 1) {
- x = x | x >> i;
- }
- return x + 1;
+THREE.MTLLoader.nextHighestPowerOfTwo_ = function(x)
+{
+ --x;
+ for (var i = 1; i < 32; i <<= 1) {
+ x = x | x >> i;
}
+ return x + 1;
};
| false |
Other | mrdoob | three.js | 8d40dba44b5d711185994162c6cf1c52e5a78baf.json | make clone of materials | src/materials/MeshFaceMaterial.js | @@ -11,7 +11,7 @@ THREE.MeshFaceMaterial = function ( materials ) {
THREE.MeshFaceMaterial.prototype.clone = function () {
var material = new THREE.MeshFaceMaterial();
- material.materials = this.materials;
+ material.materials = this.materials.slice(0);
return material;
}; | false |
Other | mrdoob | three.js | 8a960ad7fda5c87af940bb31b9c571c3cab92be0.json | add getDescendants to Object3D | src/core/Object3D.js | @@ -206,6 +206,23 @@ THREE.Object3D.prototype = {
return undefined;
},
+
+ getDescendants: function (returnValue) {
+ var children = this.children,l = children.length,child;
+
+ if (returnValue === undefined){
+ returnValue = [];
+ }
+
+ for (var i = 0; i < l ; i++){
+ child = children[i];
+ returnValue.push(child);
+ child.getDescendants(returnValue);
+ };
+
+ return returnValue;
+
+ },
updateMatrix: function () {
| false |
Other | mrdoob | three.js | ce183b552aa2321013a59e81f7790416f2aa6ad9.json | Add a bit of documentation for the Projector class | docs/api/core/Projector.html | @@ -25,12 +25,31 @@ <h3>.unprojectVector( [page:Vector3 vector], [page:Camera camera] ) [page:Vector
<h3>.pickingRay( [page:Vector3 vector], [page:Camera camera] ) [page:Ray]</h3>
<div>
- Translates a 2D point from NDC to a [page:Ray] that can be used for picking.
+ Translates a 2D point from NDC (<em>Normalized Device Coordinates</em>) to a [page:Ray] that can be used for picking. NDC range from [-1..1] in x (left to right) and [1.0 .. -1.0] in y (top to bottom).
</div>
<h3>.projectGraph( [page:Object3D root], [page:Boolean sort] ) [page:Object]</h3>
+ <div>
+ [page:Object3D root] β object to project.<br />
+ [page:Boolean sort] β select whether to sort elements using the <a href="http://en.wikipedia.org/wiki/Painter%27s_algorithm">Painter's algorithm</a>.
+ </div>
+ <div>
+ Recursively create a rendering graph, starting from the <em>root</em> object.
+ </div>
<h3>.projectScene( [page:Scene scene], [page:Camera camera], [page:Boolean sort] ) [page:Object]</h3>
+ <div>
+ [page:Scene scene] β scene to project.<br />
+ [page:Camera camera] β camera to use in the projection.<br />
+ [page:Boolean sort] β select whether to sort elements using the <a href="http://en.wikipedia.org/wiki/Painter%27s_algorithm">Painter's algorithm</a>.
+ </div>
+
+ <div>
+ Transforms a 3D [page:Scene scene] object into 2D render data that can be rendered in a screen with your renderer of choice, projecting and clipping things out according to the used camera.
+ </div>
+ <div>
+ If the <em>scene</em> were a real scene, this method would be the equivalent of taking a picture with the <em>camera</em> (and developing the film would be the next step, using a Renderer).
+ </div>
<h2>Source</h2> | false |
Other | mrdoob | three.js | 0715dd3eb37f89cca4888d6aa9d80bc728fb1ca0.json | Add example for gpu-assisted picking | examples/webgl_gpu_picking.html | @@ -0,0 +1,241 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - gpu picking</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <style>
+ body {
+ font-family: Monospace;
+ background-color: #f0f0f0;
+ margin: 0px;
+ overflow: hidden;
+ }
+
+ .info {
+ position: absolute;
+ background-color: black;
+ opacity: 0.8;
+ color: white;
+ text-align: center;
+ top: 0px;
+ width: 100%;
+ }
+
+ .info a {
+ color: #00ffff;
+ }
+ </style>
+ </head>
+ <body>
+
+ <div class="info">
+ <a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl - gpu picking
+ </div>
+
+ <div id="container"></div>
+
+ <script src="../build/Three.js"></script>
+
+ <script src="js/Stats.js"></script>
+
+ <script>
+
+ var container, stats;
+ var camera, controls, scene, renderer;
+ var pickingData = [], pickingTexture, pickingScene;
+ var objects = [];
+ var highlightBox;
+
+ var mouse = new THREE.Vector2(),
+ offset = new THREE.Vector3(10, 10, 10);
+
+ init();
+ animate();
+
+ function init() {
+
+ container = document.getElementById("container");
+
+ scene = new THREE.Scene();
+ pickingScene = new THREE.Scene();
+ pickingTexture = new THREE.WebGLRenderTarget(window.innerWidth, window.innerHeight);
+ pickingTexture.generateMipmaps = false;
+
+ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
+ camera.position.z = 1000;
+ scene.add( camera );
+
+ controls = new THREE.TrackballControls( camera );
+ controls.rotateSpeed = 1.0;
+ controls.zoomSpeed = 1.2;
+ controls.panSpeed = 0.8;
+ controls.noZoom = false;
+ controls.noPan = false;
+ controls.staticMoving = true;
+ controls.dynamicDampingFactor = 0.3;
+
+ scene.add( new THREE.AmbientLight( 0x555555 ) );
+
+ var light = new THREE.SpotLight( 0xffffff, 1.5 );
+
+ light.position.set( 0, 500, 2000 );
+ light.castShadow = true;
+
+ light.shadowCameraNear = 200;
+ light.shadowCameraFar = camera.far;
+ light.shadowCameraFov = 50;
+
+ light.shadowBias = -0.00022;
+ light.shadowDarkness = 0.5;
+
+ light.shadowMapWidth = 1024;
+ light.shadowMapHeight = 1024;
+
+ scene.add( light );
+
+ var geometry = new THREE.Geometry(),
+ pickingGeometry = new THREE.Geometry(),
+ pickingMaterial = new THREE.MeshBasicMaterial({
+ vertexColors: THREE.VertexColors
+ }),
+ defaultMaterial = new THREE.MeshLambertMaterial({
+ color: 0xffffff,
+ shading: THREE.FlatShading,
+ vertexColors: THREE.VertexColors
+ });
+
+ function applyVertexColors(g, c) {
+ g.faces.forEach(function(f){
+ var n = (f instanceof THREE.Face3) ? 3 : 4;
+ for(var j=0; j<n; j++){
+ f.vertexColors[j] = c;
+ }
+ });
+ }
+
+ for ( var i = 0; i < 5000; i ++ ) {
+ var position = new THREE.Vector3();
+ position.x = Math.random() * 10000 - 5000;
+ position.y = Math.random() * 6000 - 3000;
+ position.z = Math.random() * 8000 - 4000;
+
+ var rotation = new THREE.Vector3();
+ rotation.x = ( Math.random() * 2 * Math.PI);
+ rotation.y = ( Math.random() * 2 * Math.PI);
+ rotation.z = ( Math.random() * 2 * Math.PI);
+
+ var scale = new THREE.Vector3();
+ scale.x = Math.random() * 200 + 100;
+ scale.y = Math.random() * 200 + 100;
+ scale.z = Math.random() * 200 + 100;
+
+ //give the geom's vertices a random color, to be displayed
+ var geom = new THREE.CubeGeometry(1, 1, 1);
+ var color = new THREE.Color(Math.random() * 0xffffff);
+ applyVertexColors(geom, color);
+ var cube = new THREE.Mesh(geom);
+ cube.position.copy(position);
+ cube.rotation.copy(rotation);
+ cube.scale.copy(scale);
+ THREE.GeometryUtils.merge(geometry, cube);
+
+ //give the pickingGeom's vertices a color corresponding to the "id"
+ var pickingGeom = new THREE.CubeGeometry(1, 1, 1);
+ var pickingColor = new THREE.Color(i);
+ applyVertexColors(pickingGeom, pickingColor);
+ var pickingCube = new THREE.Mesh(pickingGeom);
+ pickingCube.position.copy(position);
+ pickingCube.rotation.copy(rotation);
+ pickingCube.scale.copy(scale);
+ THREE.GeometryUtils.merge(pickingGeometry, pickingCube);
+
+ pickingData[i] = {
+ position: position,
+ rotation: rotation,
+ scale: scale
+ };
+ }
+ var drawnObject = new THREE.Mesh(geometry, defaultMaterial);
+ //drawnObject.castShadow = true;
+ //drawnObject.receiveShadow = true;
+ scene.add(drawnObject);
+
+ pickingScene.add(new THREE.Mesh(pickingGeometry, pickingMaterial));
+
+ highlightBox = new THREE.Mesh(new THREE.CubeGeometry(1, 1, 1), new THREE.MeshLambertMaterial({color: 0xffff00}));
+ scene.add(highlightBox);
+
+ projector = new THREE.Projector();
+
+ renderer = new THREE.WebGLRenderer( { antialias: true, clearColor: 0xffffff } );
+ renderer.sortObjects = false;
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ renderer.shadowMapEnabled = true;
+ renderer.shadowMapSoft = true;
+
+ container.appendChild( renderer.domElement );
+
+ stats = new Stats();
+ stats.domElement.style.position = 'absolute';
+ stats.domElement.style.top = '0px';
+ container.appendChild( stats.domElement );
+
+ renderer.domElement.addEventListener('mousemove', onMouseMove);
+ }
+ //
+
+ function onMouseMove(e) {
+ mouse.x = e.clientX;
+ mouse.y = e.clientY;
+ }
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ render();
+ stats.update();
+
+ }
+
+ function pick() {
+ //render the picking scene off-screen
+ var gl = self.renderer.getContext();
+ renderer.render(pickingScene, camera, pickingTexture);
+ var pixelBuffer = new Uint8Array(4);
+
+ //read the pixel under the mouse from the texture
+ gl.readPixels(mouse.x, pickingTexture.height - mouse.y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixelBuffer);
+
+ //interpret the pixel as an ID
+ var id = (pixelBuffer[0] << 16) | (pixelBuffer[1] << 8) | (pixelBuffer[2]);
+ var data = pickingData[id];
+ if(data){
+ //move our highlightBox so that it surrounds the picked object
+ if(data.position && data.rotation && data.scale){
+ highlightBox.position.copy(data.position);
+ highlightBox.rotation.copy(data.rotation);
+ highlightBox.scale.copy(data.scale).addSelf(offset);
+ highlightBox.visible = true;
+ }
+ } else {
+ highlightBox.visible = false;
+ }
+ }
+
+ function render() {
+
+ controls.update();
+
+ pick();
+
+ renderer.render( scene, camera );
+
+ }
+
+ </script>
+
+ </body>
+</html> | false |
Other | mrdoob | three.js | c9e88e32a7e6a8a03b2d5a619ee7cd61942aa772.json | make curve createGeometry 2D/3D friendly | src/extras/core/CurvePath.js | @@ -204,7 +204,7 @@ THREE.CurvePath.prototype.createGeometry = function( points ) {
for ( var i = 0; i < points.length; i ++ ) {
- geometry.vertices.push( new THREE.Vector3( points[ i ].x, points[ i ].y, points[ i ].z ) );
+ geometry.vertices.push( new THREE.Vector3( points[ i ].x, points[ i ].y, points[ i ].z || 0) );
}
| false |
Other | mrdoob | three.js | 7409249bc706a51b9c6319209e392c5dd7cf1dda.json | Add FirstPersonControls documentation draft | docs/api/extras/controls/FirstPersonControls.html | @@ -1,26 +1,130 @@
<h1>[name]</h1>
-<div class="desc">todo</div>
+<div class="desc">An extra add-on for creating and using mouse and keyboard controls akin to those found in <a href="http://en.wikipedia.org/wiki/First-person_shooter">First-Person Shooters</a> (hence the class name).</div>
+<div class="desc">Once attached to a camera object, the position of the camera and its lookAt target can be controlled using the mouse and certain keys (depending on the chosen configuration).</div>
+
+<div class="desc">The default behaviour is to "pan around" when moving the mouse, and translate forwards or backwards with the left and right buttons pressed. Additionally, the following keys are also enabled:<br /><br />
+W β moves forward (equivalent to pressing the left button)<br />
+A β moves leftwards<br />
+S β moves backwards (equivalent to pressing the right button)<br />
+D β moves rightwards<br />
+R β moves up<br />
+F β moves down<br />
+Q β toggle freezing (when "frozen", no changes in the camera position or target will happen)<br />
+</div>
+
+<div class="desc">The camera 'target' is always 100 units ahead of the camera.</div>
<h2>Constructor</h2>
-<h3>[name]()</h3>
+<h3>[name]( [page:Object object], [page:Element domElement] )</h3>
+<div>
+object β A camera or another object with similar behaviour (has a <em>position</em> property and a <em>lookAt</em> method).<br />
+domElement β the element that contains the canvas or WebGL renderer holding the camera we'll control (optional, will use document if nothing is specified)<br />
+</div>
<h2>Properties</h2>
-<h3>.[page:Vector3 todo]</h3>
+<h3>.[page:Object object]</h3>
+<div>
+The camera or object whose <em>position</em> properties will be modified.
+</div>
+
+<h3>.[page:Element domElement]</h3>
+<div>
+Used for determining the viewport dimensions. If nothing is specified, the current HTML document will be used. Else, the specified element dimensions (offsetWidth and offsetHeight) will be used. Additionally, allowing the element to get focused via tabbing is disabled.
+</div>
+
+<h3>.[page:Boolean lookVertical]</h3>
+<div>
+Allows the camera to change its vertical angle, thus modifying the camera pitch.
+If disabled, the mouse movements will only change the yaw.
+</div>
+<div>
+Default is true.
+</div>
+
+<h3>.[page:Boolean autoForward]</h3>
+<div>
+Toggle between automatically moving forward without user intervention (i.e. without pressing the left button or the W key) or not. If in <em>autoForward</em> mode, pressing the right button or the S key will still go backwards (temporarily stopping the forward motion).
+</div>
+<div>
+Default is false.
+</div>
+
+<h3>.[page:Boolean activeLook]</h3>
+<div>
+If true, left clicking moves forward and right clicking moves backwards, and moving the mouse around changes the point of view.<br />
+If false, nothing happens on mouse events.
+</div>
+
+<div>Default is true.</div>
+
+<h3>.[page:Boolean heightSpeed]</h3>
+
+<div>??? TODO</div>
+
+<div>
+Default is false.
+</div>
+
+<h3>.[page:Float heightCoef]</h3>
+
+<div>??? TODO</div>
+
+<div>
+Default is 1.0.
+</div>
+
+<h3>.[page:Float heightMin]</h3>
+
+<div>??? TODO</div>
+
+<div>
+Default is 0.0.
+</div>
+
+<h3>.[page:Boolean constrainVertical]</h3>
+
+<div>Limit camera's pitch range. If true, the pitch angle can only be in the [verticalMin, verticalMax] range.</div>
+
+<div>
+Default is false.
+</div>
+
+<h3>.[page:Float verticalMin]</h3>
+
+<div>See <em>constrainVertical</em> property.</div>
+
+<div>
+Default is 0.0.
+</div>
+<h3>.[page:Float verticalMax]</h3>
+
+<div>See <em>constrainVertical</em> property.</div>
+
+<div>
+Default is Math.PI.
+</div>
<h2>Methods</h2>
-<h3>.todo( [page:Vector3 todo] )</h3>
+<h3>.update( [page:Float delta] )</h3>
+<div>
+Update values using delta as time difference<br />
+<br />
+delta β time elapsed since the last time update was called.<br />
+</div>
+
+<h3>.handleResize( )</h3>
<div>
-todo β todo<br />
+Recalculate viewport dimensions.
</div>
<h2>Source</h2>
-[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
\ No newline at end of file
+[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] | false |
Other | mrdoob | three.js | 58dd3acf92d2bd6693501df2b50f953e72cf1b38.json | fix the redeclaration and fix performance | src/renderers/WebGLRenderer.js | @@ -3255,7 +3255,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var gonnaUse = [];
for ( i = 0; i < il; i ++ ) {
- var candidateInfluence = influences[ i ]
+ candidateInfluence = influences[ i ]
if ( candidateInfluence > 0 ) {
gonnaUse.push(i);
} | false |
Other | mrdoob | three.js | 02a35148d44010b683a26a99561160269b71063a.json | fix the last fix | src/renderers/WebGLRenderer.js | @@ -3266,7 +3266,7 @@ THREE.WebGLRenderer = function ( parameters ) {
gonnaUse.length = material.numSupportedMorphTargets
} else if (gonnaUse.length > material.numSupportedMorphNormals){
gonnaUse.sort(sortNumerical);
- } else if (gonnaUse.length = 0){
+ } else if (gonnaUse.length === 0){
gonnaUse.push(0);
};
| false |
Other | mrdoob | three.js | d1261c9293d6b743d417c4e2da307f2c8685caee.json | fix the normals for morphs | src/renderers/WebGLRenderer.js | @@ -3296,6 +3296,9 @@ THREE.WebGLRenderer = function ( parameters ) {
object.__webglMorphTargetInfluences[ m ] = influences[ gonnaUse[m]];
} else {
_gl.vertexAttribPointer( attributes[ "morphTarget" + m ], 3, _gl.FLOAT, false, 0, 0 );
+ if ( material.morphNormals ) {
+ _gl.vertexAttribPointer( attributes[ "morphNormal" + m ], 3, _gl.FLOAT, false, 0, 0 );
+ }
object.__webglMorphTargetInfluences[ m ] = 0;
}
//used[ candidate ] = 1; | false |
Other | mrdoob | three.js | 235f35a5e20d47f52be35489d3d95f099338a941.json | test face4s generation in parametricgeometry | src/extras/geometries/ParametricGeometry.js | @@ -12,7 +12,7 @@ THREE.ParametricGeometry = function ( slices, stacks, func ) {
var faces = this.faces;
var uvs = this.faceVertexUvs[ 0 ];
- var face3 = true;
+ var face3 = !true;
var i, il, j, p;
var u, v;
@@ -50,20 +50,30 @@ THREE.ParametricGeometry = function ( slices, stacks, func ) {
uvc = new THREE.UV( ( i + 1 ) / slices, j / stacks );
uvd = new THREE.UV( ( i + 1 ) / slices, ( j + 1 ) / stacks );
- faces.push( new THREE.Face3( a, b, c ) );
- faces.push( new THREE.Face3( b, d, c ) );
+ if ( face3 ) {
+
+ faces.push( new THREE.Face3( a, b, c ) );
+ faces.push( new THREE.Face3( b, d, c ) );
+
+ uvs.push( [ uva, uvb, uvc ] );
+ uvs.push( [ uvb, uvd, uvc ] );
+
+ } else {
+
+ faces.push( new THREE.Face4( a, b, d, c ) );
+ uvs.push( [ uva, uvb, uvc, uvd ] );
+
+ }
- uvs.push( [ uva, uvb, uvc ] );
- uvs.push( [ uvb, uvd, uvc ] );
}
}
- console.log(this);
+ // console.log(this);
// magic bullet
var diff = this.mergeVertices();
- console.log('removed ', diff, ' vertices by merging')
+ console.log('removed ', diff, ' vertices by merging');
this.computeCentroids();
this.computeFaceNormals(); | false |
Other | mrdoob | three.js | 8874516ec257f1782adfb7276a557973ab0d928d.json | Allow non-indexed BufferGeometries
Allow non-indexed BufferGeometries to render the entire buffer in a single draw call rather than a draw call per 2^16-1 vetexes | src/renderers/WebGLRenderer.js | @@ -3266,102 +3266,185 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( object instanceof THREE.Mesh ) {
- var offsets = geometry.offsets;
+ var index = geometry.attributes["index"];
+ if (index) {
+ // Indexed triangles
+ var offsets = geometry.offsets;
- // if there is more than 1 chunk
- // must set attribute pointers to use new offsets for each chunk
- // even if geometry and materials didn't change
+ // if there is more than 1 chunk
+ // must set attribute pointers to use new offsets for each chunk
+ // even if geometry and materials didn't change
- if ( offsets.length > 1 ) updateBuffers = true;
+ if (offsets.length > 1) updateBuffers = true;
- for ( var i = 0, il = offsets.length; i < il; ++ i ) {
+ for (var i = 0, il = offsets.length; i < il; ++i) {
- var startIndex = offsets[ i ].index;
+ var startIndex = offsets[i].index;
- if ( updateBuffers ) {
+ if (updateBuffers) {
- // vertices
+ // vertices
- var position = geometry.attributes[ "position" ];
- var positionSize = position.itemSize;
+ var position = geometry.attributes["position"];
+ var positionSize = position.itemSize;
- _gl.bindBuffer( _gl.ARRAY_BUFFER, position.buffer );
- enableAttribute( attributes.position );
- _gl.vertexAttribPointer( attributes.position, positionSize, _gl.FLOAT, false, 0, startIndex * positionSize * 4 ); // 4 bytes per Float32
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, position.buffer);
+ enableAttribute(attributes.position);
+ _gl.vertexAttribPointer(attributes.position, positionSize, _gl.FLOAT, false, 0, startIndex * positionSize * 4); // 4 bytes per Float32
- // normals
+ // normals
- var normal = geometry.attributes[ "normal" ];
+ var normal = geometry.attributes["normal"];
- if ( attributes.normal >= 0 && normal ) {
+ if (attributes.normal >= 0 && normal) {
- var normalSize = normal.itemSize;
+ var normalSize = normal.itemSize;
- _gl.bindBuffer( _gl.ARRAY_BUFFER, normal.buffer );
- enableAttribute( attributes.normal );
- _gl.vertexAttribPointer( attributes.normal, normalSize, _gl.FLOAT, false, 0, startIndex * normalSize * 4 );
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, normal.buffer);
+ enableAttribute(attributes.normal);
+ _gl.vertexAttribPointer(attributes.normal, normalSize, _gl.FLOAT, false, 0, startIndex * normalSize * 4);
- }
+ }
- // uvs
+ // uvs
- var uv = geometry.attributes[ "uv" ];
+ var uv = geometry.attributes["uv"];
- if ( attributes.uv >= 0 && uv ) {
+ if (attributes.uv >= 0 && uv) {
- var uvSize = uv.itemSize;
+ var uvSize = uv.itemSize;
- _gl.bindBuffer( _gl.ARRAY_BUFFER, uv.buffer );
- enableAttribute( attributes.uv );
- _gl.vertexAttribPointer( attributes.uv, uvSize, _gl.FLOAT, false, 0, startIndex * uvSize * 4 );
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, uv.buffer);
+ enableAttribute(attributes.uv);
+ _gl.vertexAttribPointer(attributes.uv, uvSize, _gl.FLOAT, false, 0, startIndex * uvSize * 4);
- }
+ }
- // colors
+ // colors
- var color = geometry.attributes[ "color" ];
+ var color = geometry.attributes["color"];
- if ( attributes.color >= 0 && color ) {
+ if (attributes.color >= 0 && color) {
- var colorSize = color.itemSize;
+ var colorSize = color.itemSize;
- _gl.bindBuffer( _gl.ARRAY_BUFFER, color.buffer );
- enableAttribute( attributes.color );
- _gl.vertexAttribPointer( attributes.color, colorSize, _gl.FLOAT, false, 0, startIndex * colorSize * 4 );
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, color.buffer);
+ enableAttribute(attributes.color);
+ _gl.vertexAttribPointer(attributes.color, colorSize, _gl.FLOAT, false, 0, startIndex * colorSize * 4);
- }
+ }
- // tangents
+ // tangents
- var tangent = geometry.attributes[ "tangent" ];
+ var tangent = geometry.attributes["tangent"];
- if ( attributes.tangent >= 0 && tangent ) {
+ if (attributes.tangent >= 0 && tangent) {
- var tangentSize = tangent.itemSize;
+ var tangentSize = tangent.itemSize;
- _gl.bindBuffer( _gl.ARRAY_BUFFER, tangent.buffer );
- enableAttribute( attributes.tangent );
- _gl.vertexAttribPointer( attributes.tangent, tangentSize, _gl.FLOAT, false, 0, startIndex * tangentSize * 4 );
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, tangent.buffer);
+ enableAttribute(attributes.tangent);
+ _gl.vertexAttribPointer(attributes.tangent, tangentSize, _gl.FLOAT, false, 0, startIndex * tangentSize * 4);
- }
+ }
- // indices
+ // indices
+
+ _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, index.buffer);
- var index = geometry.attributes[ "index" ];
+ }
- _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer );
+ // render indexed triangles
- }
+ _gl.drawElements(_gl.TRIANGLES, offsets[i].count, _gl.UNSIGNED_SHORT, offsets[i].start * 2); // 2 bytes per Uint16
- // render indexed triangles
+ _this.info.render.calls++;
+ _this.info.render.vertices += offsets[i].count; // not really true, here vertices can be shared
+ _this.info.render.faces += offsets[i].count / 3;
- _gl.drawElements( _gl.TRIANGLES, offsets[ i ].count, _gl.UNSIGNED_SHORT, offsets[ i ].start * 2 ); // 2 bytes per Uint16
+ }
- _this.info.render.calls ++;
- _this.info.render.vertices += offsets[ i ].count; // not really true, here vertices can be shared
- _this.info.render.faces += offsets[ i ].count / 3;
+ }
+ else
+ {
+ // non-indexed triangles
+ if (updateBuffers) {
- }
+ // vertices
+ var position = geometry.attributes["position"];
+ var positionSize = position.itemSize;
+
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, position.buffer);
+ enableAttribute(attributes.position);
+ _gl.vertexAttribPointer(attributes.position, positionSize, _gl.FLOAT, false, 0, 0);
+
+ // normals
+
+ var normal = geometry.attributes["normal"];
+
+ if (attributes.normal >= 0 && normal) {
+
+ var normalSize = normal.itemSize;
+
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, normal.buffer);
+ enableAttribute(attributes.normal);
+ _gl.vertexAttribPointer(attributes.normal, normalSize, _gl.FLOAT, false, 0, 0);
+
+ }
+
+ // uvs
+
+ var uv = geometry.attributes["uv"];
+
+ if (attributes.uv >= 0 && uv) {
+
+ var uvSize = uv.itemSize;
+
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, uv.buffer);
+ enableAttribute(attributes.uv);
+ _gl.vertexAttribPointer(attributes.uv, uvSize, _gl.FLOAT, false, 0, 0);
+
+ }
+
+ // colors
+
+ var color = geometry.attributes["color"];
+
+ if (attributes.color >= 0 && color) {
+
+ var colorSize = color.itemSize;
+
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, color.buffer);
+ enableAttribute(attributes.color);
+ _gl.vertexAttribPointer(attributes.color, colorSize, _gl.FLOAT, false, 0, 0);
+
+ }
+
+ // tangents
+
+ var tangent = geometry.attributes["tangent"];
+
+ if (attributes.tangent >= 0 && tangent) {
+
+ var tangentSize = tangent.itemSize;
+
+ _gl.bindBuffer(_gl.ARRAY_BUFFER, tangent.buffer);
+ enableAttribute(attributes.tangent);
+ _gl.vertexAttribPointer(attributes.tangent, tangentSize, _gl.FLOAT, false, 0, 0);
+
+ }
+
+ }
+
+ // render non-indexed triangles
+
+ _gl.drawArrays(_gl.TRIANGLES, 0, position.numItems / 3);
+
+ _this.info.render.calls++;
+ _this.info.render.vertices += position.numItems / 3;
+ _this.info.render.faces += position.numItems / 3 / 3;
+
+ }
// render particles
| false |
Other | mrdoob | three.js | 71dbd0092f7ef58c30c6efd1db39fb324d600215.json | Add closure sourcemaps support to build.py
- add --sourcemaps flag to build.py
- see #2465
- node.js build script could support sourcemaps with uglifyjs2 | utils/build.py | @@ -15,6 +15,7 @@ def main(argv=None):
parser.add_argument('--externs', action='append', default=['externs/common.js'])
parser.add_argument('--minify', action='store_true', default=False)
parser.add_argument('--output', default='../build/three.js')
+ parser.add_argument('--sourcemaps', action='store_true', default=False)
args = parser.parse_args()
@@ -24,32 +25,44 @@ def main(argv=None):
print(' * Building ' + output)
+ # enable sourcemaps support
+
+ if args.sourcemaps:
+ sourcemap = '../build/three.js.map'
+ sourcemapping = '\n//@ sourceMappingURL=' + sourcemap
+ sourcemapargs = ' --create_source_map ' + sourcemap + ' --source_map_format=V3'
+ else:
+ sourcemap = sourcemapping = sourcemapargs = ''
+
fd, path = tempfile.mkstemp()
tmp = open(path, 'w')
+ sources = []
for include in args.include:
with open('includes/' + include + '.json','r') as f: files = json.load(f)
for filename in files:
+ sources.append(filename)
with open(filename, 'r') as f: tmp.write(f.read())
tmp.close()
# save
if args.minify is False:
-
shutil.copy(path, output)
os.chmod(output, 0o664); # temp files would usually get 0600
else:
externs = ' --externs '.join(args.externs)
- os.system('java -jar compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --externs %s --jscomp_off=checkTypes --language_in=ECMASCRIPT5_STRICT --js %s --js_output_file %s' % (externs, path, output))
+ source = ' '.join(sources)
+ cmd = 'java -jar compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --externs %s --jscomp_off=checkTypes --language_in=ECMASCRIPT5_STRICT --js %s --js_output_file %s %s' % (externs, source, output, sourcemapargs)
+ os.system(cmd)
# header
with open(output,'r') as f: text = f.read()
- with open(output,'w') as f: f.write('// three.js - http://github.com/mrdoob/three.js\n' + text)
+ with open(output,'w') as f: f.write('// three.js - http://github.com/mrdoob/three.js\n' + text + sourcemapping)
os.close(fd)
os.remove(path) | false |
Other | mrdoob | three.js | 47010c1918c3ec5b0530d94b2b632390589d1e1f.json | add the update for real now | utils/build.js | @@ -114,6 +114,12 @@ function buildIncludes(files, filename){
output(text.join("\n"), filename + '.js');
}
+function getFileNames(){
+ "use strict";
+ var fileName = "utils/files.json";
+ var data = JSON.parse(fs.readFileSync(fileName,'utf8'));
+ return data;
+}
function parse_args(){
"use strict";
@@ -141,12 +147,13 @@ function main(){
var args = parse_args();
var debug = args.debug;
var minified = args.minified;
+ var files = getFileNames();
var config = [
- ['Three', 'includes', '', COMMON_FILES.concat(EXTRAS_FILES), args.common],
- ['ThreeCanvas', 'includes_canvas', '', CANVAS_FILES, args.canvas],
- ['ThreeWebGL', 'includes_webgl', '', WEBGL_FILES, args.webgl],
- ['ThreeExtras', 'includes_extras', 'externs_extras', EXTRAS_FILES, args.extras]
+ ['Three', 'includes', '', files["COMMON"].concat(files["EXTRAS"]), args.common],
+ ['ThreeCanvas', 'includes_canvas', '', files["CANVAS"], args.canvas],
+ ['ThreeWebGL', 'includes_webgl', '', files["WEBGL"], args.webgl],
+ ['ThreeExtras', 'includes_extras', 'externs_extras', files["EXTRAS"], args.extras]
];
| false |
Other | mrdoob | three.js | bab765decdba67797e6a7de894dba25db16f2323.json | remove _FILES postfixes | utils/build.py | @@ -154,10 +154,10 @@ def main(argv=None):
files = getFileNames()
config = [
- ['Three', 'includes', '', files["COMMON_FILES"] + files["EXTRAS_FILES"], args.common],
- ['ThreeCanvas', 'includes_canvas', '', files["CANVAS_FILES"], args.canvas],
- ['ThreeWebGL', 'includes_webgl', '', files["WEBGL_FILES"], args.webgl],
- ['ThreeExtras', 'includes_extras', 'externs_extras', files["EXTRAS_FILES"], args.extras]
+ ['Three', 'includes', '', files["COMMON"] + files["EXTRAS"], args.common],
+ ['ThreeCanvas', 'includes_canvas', '', files["CANVAS"], args.canvas],
+ ['ThreeWebGL', 'includes_webgl', '', files["WEBGL"], args.webgl],
+ ['ThreeExtras', 'includes_extras', 'externs_extras', files["EXTRAS"], args.extras]
]
for fname_lib, fname_inc, fname_externs, files, enabled in config: | true |
Other | mrdoob | three.js | bab765decdba67797e6a7de894dba25db16f2323.json | remove _FILES postfixes | utils/files.json | @@ -1,5 +1,5 @@
{
- "COMMON_FILES" : [
+ "COMMON" : [
"Three.js",
"core/Clock.js",
"core/Color.js",
@@ -77,7 +77,7 @@
"renderers/renderables/RenderableLine.js"
],
- "EXTRAS_FILES" : [
+ "EXTRAS" : [
"extras/ColorUtils.js",
"extras/GeometryUtils.js",
"extras/ImageUtils.js",
@@ -132,7 +132,7 @@
"extras/shaders/ShaderSprite.js"
],
- "CANVAS_FILES" : [
+ "CANVAS" : [
"Three.js",
"core/Color.js",
"core/Vector2.js",
@@ -194,7 +194,7 @@
"renderers/renderables/RenderableLine.js"
],
- "WEBGL_FILES" : [
+ "WEBGL" : [
"Three.js",
"core/Color.js",
"core/Vector2.js", | true |
Other | mrdoob | three.js | 134125e7c46e65d5f0e5a37b429c2dc1d01b66a6.json | Add small description to Frustum docs. | docs/api/core/Frustum.html | @@ -9,7 +9,7 @@
<body>
<h1>[name]</h1>
- <div class="desc"></div>
+ <div class="desc"><a href="http://en.wikipedia.org/wiki/Frustum">Frustums</a> are used to determine what is inside the camera's field of view. They help speed up the rendering process.</div>
<h2>Constructor</h2> | false |
Other | mrdoob | three.js | 5ac0c5c19376eef3e956f7c580c0967c01bb221d.json | Fix references to animationCache in stop function. | src/extras/animation/KeyFrameAnimation.js | @@ -142,13 +142,14 @@ THREE.KeyFrameAnimation.prototype.stop = function() {
// reset JIT matrix and remove cache
- for ( var h = 0; h < this.hierarchy.length; h++ ) {
+ for ( var h = 0; h < this.data.hierarchy.length; h++ ) {
+
+ var obj = this.hierarchy[ h ];
+ var node = this.data.hierarchy[ h ];
- var obj = this.hierarchy[ h ];
+ if ( node.animationCache !== undefined ) {
- if ( obj.animationCache !== undefined ) {
-
- var original = obj.animationCache.originalMatrix;
+ var original = node.animationCache.originalMatrix;
if( obj instanceof THREE.Bone ) {
@@ -162,7 +163,7 @@ THREE.KeyFrameAnimation.prototype.stop = function() {
}
- delete obj.animationCache;
+ delete node.animationCache;
}
@@ -226,7 +227,6 @@ THREE.KeyFrameAnimation.prototype.update = function( deltaTimeMS ) {
prev = this.getPrevKeyWith( sid, h, end );
if ( prev ) {
-
prev.apply( sid );
}
@@ -338,8 +338,10 @@ THREE.KeyFrameAnimation.prototype.update = function( deltaTimeMS ) {
animationCache.nextKey = nextKey;
}
-
- prevKey.interpolate( nextKey, currentTime );
+ if(nextKey.time >= currentTime)
+ prevKey.interpolate( nextKey, currentTime );
+ else
+ prevKey.interpolate( nextKey, nextKey.time);
}
| false |
Other | mrdoob | three.js | bf644ea5ff0f784c8991122692677c30cec39e1d.json | fix cancelRequestAnimationFrame polyfill | src/Three.js | @@ -23,7 +23,7 @@ if ( ! self.Int32Array ) {
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
- || window[vendors[x]+'RequestCancelAnimationFrame'];
+ || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame) | false |
Other | mrdoob | three.js | 2f234a2ac8b2fbac49997050caf9adcd896ca35d.json | change child reference to object reference | src/core/Object3D.js | @@ -132,11 +132,11 @@ THREE.Object3D.prototype = {
remove: function ( object ) {
var scene = this;
- var childIndex = this.children.indexOf( child );
+ var childIndex = this.children.indexOf( object );
if ( childIndex !== - 1 ) {
- child.parent = undefined;
+ object.parent = undefined;
this.children.splice( childIndex, 1 );
// remove from scene
@@ -149,7 +149,7 @@ THREE.Object3D.prototype = {
if ( scene !== undefined && scene instanceof THREE.Scene ) {
- scene.removeChildRecurse( child );
+ scene.removeChildRecurse( object );
}
| false |
Other | mrdoob | three.js | 914e1c4e959696545f44c3257e42576feff80d20.json | Remove Object3D child from scene too | src/core/Object3D.js | @@ -130,14 +130,29 @@ THREE.Object3D.prototype = {
},
remove: function ( object ) {
+ var scene = this;
- var childIndex = this.children.indexOf( object );
+ var childIndex = this.children.indexOf( child );
if ( childIndex !== - 1 ) {
- object.parent = undefined;
+ child.parent = undefined;
this.children.splice( childIndex, 1 );
+ // remove from scene
+
+ while ( scene.parent !== undefined ) {
+
+ scene = scene.parent;
+
+ }
+
+ if ( scene !== undefined && scene instanceof THREE.Scene ) {
+
+ scene.removeChildRecurse( child );
+
+ }
+
}
}, | false |
Other | mrdoob | three.js | 340f82394fb41ab1df5527ce7979c779ab459363.json | fix whitespace in Object3D.js | src/core/Object3D.js | @@ -130,30 +130,30 @@ THREE.Object3D.prototype = {
},
removeChild: function ( child ) {
- var scene = this;
+ var scene = this;
var childIndex = this.children.indexOf( child );
if ( childIndex !== - 1 ) {
- child.parent = undefined;
- this.children.splice( childIndex, 1 );
+ child.parent = undefined;
+ this.children.splice( childIndex, 1 );
- // remove from scene
+ // remove from scene
- while ( scene.parent !== undefined ) {
+ while ( scene.parent !== undefined ) {
- scene = scene.parent;
+ scene = scene.parent;
- }
+ }
- if ( scene !== undefined && scene instanceof THREE.Scene ) {
+ if ( scene !== undefined && scene instanceof THREE.Scene ) {
- scene.removeChildRecurse( child );
+ scene.removeChildRecurse( child );
- }
+ }
- }
+ }
},
| false |
Other | mrdoob | three.js | 0825c1f612f9b77c6e6926ebb07aa839d92b9043.json | Add support for additional Euler rotation orders. | src/core/Matrix4.js | @@ -532,30 +532,116 @@ THREE.Matrix4.prototype = {
},
- setRotationFromEuler: function( v ) {
+ setRotationFromEuler: function( v, order ) {
var x = v.x, y = v.y, z = v.z,
a = Math.cos( x ), b = Math.sin( x ),
c = Math.cos( y ), d = Math.sin( y ),
- e = Math.cos( z ), f = Math.sin( z ),
- ad = a * d, bd = b * d;
+ e = Math.cos( z ), f = Math.sin( z );
- this.n11 = c * e;
- this.n12 = - c * f;
- this.n13 = d;
+ switch ( order ) {
+ case 'YXZ':
+ var ce = c * e, cf = c * f, de = d * e, df = d * f;
- this.n21 = bd * e + a * f;
- this.n22 = - bd * f + a * e;
- this.n23 = - b * c;
+ this.n11 = ce + df * b;
+ this.n12 = de * b - cf;
+ this.n13 = a * d;
- this.n31 = - ad * e + b * f;
- this.n32 = ad * f + b * e;
- this.n33 = a * c;
+ this.n21 = a * f;
+ this.n22 = a * e;
+ this.n23 = - b;
+
+ this.n31 = cf * b - de;
+ this.n32 = df + ce * b;
+ this.n33 = a * c;
+ break;
+
+ case 'ZXY':
+ var ce = c * e, cf = c * f, de = d * e, df = d * f;
+
+ this.n11 = ce - df * b;
+ this.n12 = - a * f;
+ this.n13 = de + cf * b;
+
+ this.n21 = cf + de * b;
+ this.n22 = a * e;
+ this.n23 = df - ce * b;
+
+ this.n31 = - a * d;
+ this.n32 = b;
+ this.n33 = a * c;
+ break;
+
+ case 'ZYX':
+ var ae = a * e, af = a * f, be = b * e, bf = b * f;
+
+ this.n11 = c * e;
+ this.n12 = be * d - af;
+ this.n13 = ae * d + bf;
+
+ this.n21 = c * f;
+ this.n22 = bf * d + ae;
+ this.n23 = af * d - be;
+
+ this.n31 = - d;
+ this.n32 = b * c;
+ this.n33 = a * c;
+ break;
+
+ case 'YZX':
+ var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+
+ this.n11 = c * e;
+ this.n12 = bd - ac * f;
+ this.n13 = bc * f + ad;
+
+ this.n21 = f;
+ this.n22 = a * e;
+ this.n23 = - b * e;
+
+ this.n31 = - d * e;
+ this.n32 = ad * f + bc;
+ this.n33 = ac - bd * f;
+ break;
+
+ case 'XZY':
+ var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+
+ this.n11 = c * e;
+ this.n12 = - f;
+ this.n13 = d * e;
+
+ this.n21 = ac * f + bd;
+ this.n22 = a * e;
+ this.n23 = ad * f - bc;
+
+ this.n31 = bc * f - ad;
+ this.n32 = b * e;
+ this.n33 = bd * f + ac;
+ break;
+
+ default: // 'XYZ'
+ var ae = a * e, af = a * f, be = b * e, bf = b * f;
+
+ this.n11 = c * e;
+ this.n12 = - c * f;
+ this.n13 = d;
+
+ this.n21 = af + be * d;
+ this.n22 = ae - bf * d;
+ this.n23 = - b * c;
+
+ this.n31 = bf - ae * d;
+ this.n32 = be + af * d;
+ this.n33 = a * c;
+ break;
+ }
return this;
},
+
setRotationFromQuaternion: function( q ) {
var x = q.x, y = q.y, z = q.z, w = q.w, | true |
Other | mrdoob | three.js | 0825c1f612f9b77c6e6926ebb07aa839d92b9043.json | Add support for additional Euler rotation orders. | src/core/Object3D.js | @@ -13,6 +13,7 @@ THREE.Object3D = function() {
this.position = new THREE.Vector3();
this.rotation = new THREE.Vector3();
+ this.eulerOrder = 'XYZ';
this.scale = new THREE.Vector3( 1, 1, 1 );
this.dynamic = false; // when true it retains arrays so they can be updated with __dirty*
@@ -175,7 +176,7 @@ THREE.Object3D.prototype = {
} else {
- this.matrix.setRotationFromEuler( this.rotation );
+ this.matrix.setRotationFromEuler( this.rotation, this.eulerOrder );
}
| true |
Other | mrdoob | three.js | 83628d5e151c3424f9dd2268ef910f82dca7fb28.json | Fix python for Blender 2.58
modified: 2.58/scripts/addons/io_mesh_threejs/__init__.py | utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/__init__.py | @@ -45,7 +45,7 @@
import bpy
from bpy.props import *
-from io_utils import ExportHelper, ImportHelper
+from bpy_extras.io_utils import ExportHelper, ImportHelper
# ################################################################
# Custom properties | false |
Other | mrdoob | three.js | 4fbb9056069b42a1f5b0a204faf5b8fd34577024.json | Update subdivision example | examples/webgl_geometry_subdivison.html | @@ -72,8 +72,8 @@
materials.push( [ new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, wireframe: false } ) ] );
}
-
-
+
+
var geometriesParams = [
@@ -87,7 +87,7 @@
{type: 'LatheGeometry', args: [ [
new THREE.Vector3(0,0,0),
new THREE.Vector3(0,50,50),
- new THREE.Vector3(0,0,100),
+ new THREE.Vector3(0,10,100),
new THREE.Vector3(0,50,150),
new THREE.Vector3(0,0,200) ] ]},
{type: 'TextGeometry', args: ['&', {
@@ -98,32 +98,36 @@
}]},
{type: 'PlaneGeometry', args: [ 200, 200, 4, 4 ] }
-
+
];
-
+
if (location.protocol !== "file:") {
var loader = new THREE.JSONLoader();
loader.load( 'obj/WaltHeadLo.js', function ( geometry ) {
-
+
geometriesParams.push({type: 'WaltHead', args: [ ], meshScale: 6 });
-
+
THREE.WaltHead = function() {
return THREE.GeometryUtils.clone(geometry);
};
-
+
+ updateInfo()
+
});
-
+
var loader2 = new THREE.JSONLoader();
loader2.load( 'obj/Suzanne.js', function ( geometry ) {
-
+
geometriesParams.push({type: 'Suzanne', args: [ ], scale: 100, meshScale:2 });
-
+
THREE.Suzanne = function() {
return THREE.GeometryUtils.clone(geometry);
};
-
+
+ updateInfo()
+
} );
-
+
}
@@ -157,6 +161,39 @@
}
+ function switchGeometry(i) {
+
+ geometryIndex = i;
+
+ addStuff();
+ }
+
+ function updateInfo() {
+
+ var params = geometriesParams[ geometryIndex ];
+
+ var dropdown = '<select id="dropdown" onchange="switchGeometry(this.value)">';
+
+ for ( i = 0; i < geometriesParams.length; i ++ ) {
+ dropdown += '<option value="' + i + '"';
+
+ dropdown += (geometryIndex == i) ? ' selected' : '';
+
+ dropdown += '>' + geometriesParams[i].type + '</option>';
+ }
+
+ dropdown += '</select>';
+
+ info.innerHTML = 'Drag to spin THREE.' + params.type +
+
+ '<br/><br/>Subdivisions: ' + subdivisions +
+ ' <a href="#" onclick="nextSubdivision(1); return false;">more</a>/<a href="#" onclick="nextSubdivision(-1); return false;">less</a>' +
+ '<br>Geometry: ' + dropdown + ' <a href="#" onclick="nextGeometry();return false;">next</a>' +
+ '<br/><br>Vertices count: before ' + geometry.vertices.length + ' after ' + smooth.vertices.length +
+ '<br>Face count: before ' + geometry.faces.length + ' after ' + smooth.faces.length
+ ; //+ params.args;
+ }
+
function addStuff() {
if ( cube ) {
@@ -173,7 +210,7 @@
var params = geometriesParams[ geometryIndex ];
geometry = createSomething( THREE[ params.type ], params.args );
-
+
// Scale Geometry
if (params.scale) {
geometry.applyMatrix( new THREE.Matrix4().setScale( params.scale, params.scale, params.scale ) );
@@ -187,14 +224,7 @@
smooth.mergeVertices();
modifier.modify( smooth );
- info.innerHTML = 'Drag to spin THREE.' + params.type +
-
- '<br/><br/>Subdivisions: ' + modifier.subdivisions +
- ' <a href="#" onclick="nextSubdivision(1); return false;">more</a>/<a href="#" onclick="nextSubdivision(-1); return false;">less</a>' +
- '<br>Geometry: <a href="#" onclick="nextGeometry();return false;">next</a>' +
- '<br/><br>Vertices count: before ' + geometry.vertices.length + ' after ' + smooth.vertices.length +
- '<br>Face count: before ' + geometry.faces.length + ' after ' + smooth.faces.length
- ; //+ params.args;
+ updateInfo();
var faceABCD = "abcd";
var color, f, p, n, vertexIndex;
@@ -284,21 +314,14 @@
var meshmaterials = [
- // new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true } )
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
new THREE.MeshBasicMaterial( { color: 0x405040, wireframe: true, opacity: 0.8, transparent: true } )
];
- // new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
- // new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true } )
- // new THREE.MeshFaceMaterial()
- // new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } );
- // new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } );
-
cube = THREE.SceneUtils.createMultiMaterialObject( smooth, meshmaterials );
var meshScale = params.meshScale ? params.meshScale : 1;
-
+
cube.scale.x = meshScale;
cube.scale.y = meshScale;
cube.scale.z = meshScale;
@@ -353,7 +376,7 @@
function onDocumentMouseDown( event ) {
- event.preventDefault();
+ //event.preventDefault();
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'mouseup', onDocumentMouseUp, false );
@@ -428,7 +451,7 @@
group.rotation.x = cube.rotation.x += ( targetXRotation - cube.rotation.x ) * 0.05;
group.rotation.y = cube.rotation.y += ( targetYRotation - cube.rotation.y ) * 0.05;
-
+
renderer.render( scene, camera );
}
@@ -437,3 +460,4 @@
</body>
</html>
+ | false |
Other | mrdoob | three.js | 39e993d50d77a54b692b9b72a8bdebbe42b61522.json | Include Trident.js in the EXTRAS_FILES Build array | utils/build.py | @@ -105,6 +105,7 @@
'extras/io/BinaryLoader.js',
'extras/io/SceneLoader.js',
'extras/objects/MarchingCubes.js',
+'extras/objects/Trident.js',
'extras/physics/Collisions.js',
'extras/physics/CollisionUtils.js'
] | false |
Other | mrdoob | three.js | 4fd6dce803944ad45c5615659539085a54480081.json | Fix LatheGeometry behavior | src/extras/geometries/LatheGeometry.js | @@ -20,7 +20,9 @@ THREE.LatheGeometry = function ( points, steps, angle ) {
}
- for ( var i = 0; i < _steps; i ++ ) {
+ var il = _steps + 1;
+
+ for ( var i = 0; i < il; i ++ ) {
for ( var j = 0; j < _newV.length; j ++ ) {
@@ -32,8 +34,8 @@ THREE.LatheGeometry = function ( points, steps, angle ) {
for ( var k = 0, kl = points.length; k < kl - 1; k ++ ) {
var a = i * kl + k;
- var b = ( ( i + 1 ) % _steps ) * kl + k;
- var c = ( ( i + 1 ) % _steps ) * kl + ( k + 1 ) % kl;
+ var b = ( ( i + 1 ) % il ) * kl + k;
+ var c = ( ( i + 1 ) % il ) * kl + ( k + 1 ) % kl;
var d = i * kl + ( k + 1 ) % kl;
this.faces.push( new THREE.Face4( a, b, c, d ) ); | false |
Other | mrdoob | three.js | 01852d283b95a56e9c930c3db35fc06f346975f4.json | add some improvements to frustum | build/Three.js | @@ -1023,13 +1023,17 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) {
var i, plane,
planes = this.planes;
var me = m.elements;
-
- planes[ 0 ].set( me[3] - me[0], me[7] - me[4], me[11] - me[8], me[15] - me[12] );
- planes[ 1 ].set( me[3] + me[0], me[7] + me[4], me[11] + me[8], me[15] + me[12] );
- planes[ 2 ].set( me[3] + me[1], me[7] + me[5], me[11] + me[9], me[15] + me[13] );
- planes[ 3 ].set( me[3] - me[1], me[7] - me[5], me[11] - me[9], me[15] - me[13] );
- planes[ 4 ].set( me[3] - me[2], me[7] - me[6], me[11] - me[10], me[15] - me[14] );
- planes[ 5 ].set( me[3] + me[2], me[7] + me[6], me[11] + me[10], me[15] + me[14] );
+ var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3];
+ var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7];
+ var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11];
+ var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15];
+
+ planes[ 0 ].set( me3 - me0, me7 - me4, me11 - me8, me15 - me12 );
+ planes[ 1 ].set( me3 + me0, me7 + me4, me11 + me8, me15 + me12 );
+ planes[ 2 ].set( me3 + me1, me7 + me5, me11 + me9, me15 + me13 );
+ planes[ 3 ].set( me3 - me1, me7 - me5, me11 - me9, me15 - me13 );
+ planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 );
+ planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 );
for ( i = 0; i < 6; i ++ ) {
| true |