提交 888cff1a 编写于 作者: M Mugen87

Merge remote-tracking branch 'upstream/dev' into dev30

......@@ -130,12 +130,12 @@ scene.add( camera );</code>
Updates the camera projection matrix. Must be called after any change of parameters.
</p>
<h3>[method:JSON toJSON]()</h3>
<h3>[method:Object toJSON](param:object meta])</h3>
<p>
Return the camera's data in JSON format.
meta -- object containing metadata such as textures or images in objects' descendants.<br />
Convert the camera to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -190,9 +190,10 @@ camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
Updates the camera projection matrix. Must be called after any change of parameters.
</p>
<h3>[method:JSON toJSON]()</h3>
<h3>[method:Object toJSON](param:object meta])</h3>
<p>
Return camera data in JSON format.
meta -- object containing metadata such as textures or images in objects' descendants.<br />
Convert the camera to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h2>Source</h2>
......
......@@ -327,7 +327,7 @@
<p>Sets the attributes for this BufferGeometry from an array of points.</p>
<h3>[method:Object toJSON]()</h3>
<p>Returns a JSON object representation of the BufferGeometry.</p>
<p>Convert the buffer geometry to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].</p>
<h3>[method:BufferGeometry toNonIndexed]()</h3>
<p>Return a non-index version of an indexed BufferGeometry.</p>
......
......@@ -327,8 +327,10 @@
Use [page:Object3D.scale] for typical real-time mesh scaling.
</p>
<h3>[method:JSON toJSON] ( )</h3>
<p>Convert the geometry to JSON format.</p>
<h3>[method:Object toJSON] ( )</h3>
<p>Convert the geometry to JSON format.<br />
Convert the geometry to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h3>[method:Geometry translate] ( [param:Float x], [param:Float y], [param:Float z] )</h3>
<p>
......
......@@ -389,9 +389,10 @@
Copy the given quaternion into [page:.quaternion].
</p>
<h3>[method:null toJSON]( [param:Quaternion q] )</h3>
<h3>[method:Object toJSON]( [param:object meta] )</h3>
<p>
Convert the object to JSON format.
meta -- object containing metadata such as materials, textures or images for the object.<br />
Convert the object to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h3>[method:this translateOnAxis]( [param:Vector3 axis], [param:Float distance] )</h3>
......
......@@ -13,8 +13,8 @@
<h1>[name]</h1>
<p class="desc">
Helper object to show the world-axis-aligned bounding box around an object.
Helper object to graphically show the world-axis-aligned bounding box around an object. The actual bounding box is handled with [page:Box3], this is just a visual helper for debugging.
It can be automatically resized with the [page:BoxHelper.update] method when the object it's created from is transformed.
Note that the object must have a [page:Geometry] or [page:BufferGeometry] for this to work,
so it won't work with [page:Sprite Sprites].
</p>
......@@ -28,10 +28,10 @@
<code>
var sphere = new THREE.SphereGeometry();
var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) );
var box = new THREE.BoxHelper( object, 0xffff00 );
scene.add( box );
var sphere = new THREE.SphereGeometry();
var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) );
var box = new THREE.BoxHelper( object, 0xffff00 );
scene.add( box );
</code>
......
......@@ -67,9 +67,10 @@
[page:Light source] light into this one.
</p>
<h3>[method:JSON toJSON]( [param:String meta] )</h3>
<h3>[method:Object toJSON]( [param:object meta] )</h3>
<p>
Return Light data in JSON format.
meta -- object containing metadata such as materials, textures for objects.<br />
Convert the light to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h2>Source</h2>
......
......@@ -307,10 +307,10 @@
Sets the properties based on the *values*.
</p>
<h3>[method:null toJSON]( [param:object meta] )</h3>
<h3>[method:Object toJSON]( [param:object meta] )</h3>
<p>
meta -- object containing metadata such as textures or images for the material.<br />
Convert the material to three.js JSON format.
Convert the material to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h2>Source</h2>
......
......@@ -12,11 +12,31 @@
<p class="desc">
Represents a box or cube in 3D space. The main purpose of this is to represent
the [link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Boxes]
for objects.
the world-axis-aligned bounding boxes for objects.
</p>
<h2>Example</h2>
<code>
// Creating the object whose bounding box we want to compute
var sphereObject = new THREE.Mesh(
new THREE.SphereGeometry(),
new THREE.MeshBasicMaterial( 0xff0000 )
);
// Creating the actual bounding box with Box3
sphereObject.geometry.computeBoundingBox();
var box = sphereObject.geometry.boundingBox.clone();
// ...
// In the animation loop, to keep the bounding box updated after move/rotate/scale operations
sphereObject.updateMatrixWorld( true );
box.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld );
</code>
<h2>Constructor</h2>
......
......@@ -46,9 +46,10 @@
<h2>Methods</h2>
<h3>[method:JSON toJSON]</h3>
<h3>[method:Object toJSON]</h3>
<p>
Return the scene data in JSON format.
meta -- object containing metadata such as textures or images for the scene.<br />
Convert the scene to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h3>[method:null dispose]()</h3>
......
......@@ -251,10 +251,10 @@
Make copy of the texture. Note this is not a "deep copy", the image is shared.
</p>
<h3>[method:Texture toJSON]( [param:Object meta] )</h3>
<h3>[method:Object toJSON]( [param:Object meta] )</h3>
<p>
meta -- optional object containing metadata.<br />
Convert the material to three.js JSON format.
Convert the texture to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
</p>
<h3>[method:null dispose]()</h3>
......
......@@ -126,11 +126,13 @@
<script src="js/Sidebar.Geometry.BoxGeometry.js"></script>
<script src="js/Sidebar.Geometry.CircleGeometry.js"></script>
<script src="js/Sidebar.Geometry.CylinderGeometry.js"></script>
<script src="js/Sidebar.Geometry.ExtrudeGeometry.js"></script>
<script src="js/Sidebar.Geometry.IcosahedronGeometry.js"></script>
<script src="js/Sidebar.Geometry.OctahedronGeometry.js"></script>
<script src="js/Sidebar.Geometry.PlaneGeometry.js"></script>
<script src="js/Sidebar.Geometry.RingGeometry.js"></script>
<script src="js/Sidebar.Geometry.SphereGeometry.js"></script>
<script src="js/Sidebar.Geometry.ShapeGeometry.js"></script>
<script src="js/Sidebar.Geometry.TetrahedronGeometry.js"></script>
<script src="js/Sidebar.Geometry.TorusGeometry.js"></script>
<script src="js/Sidebar.Geometry.TorusKnotGeometry.js"></script>
......
/**
* @author Temdog007 / http://github.com/Temdog007
*/
Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) {
var strings = editor.strings;
var signals = editor.signals;
var container = new UI.Row();
var geometry = object.geometry;
var parameters = geometry.parameters;
var options = parameters.options;
options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12;
options.steps = options.steps != undefined ? options.steps : 1;
options.depth = options.depth != undefined ? options.depth : 100;
options.bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;
options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4;
options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
// curveSegments
var curveSegmentsRow = new UI.Row();
var curveSegments = new UI.Integer( options.curveSegments ).onChange( update ).setRange( 1, Infinity );
curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setWidth( '90px' ) );
curveSegmentsRow.add( curveSegments );
container.add( curveSegmentsRow );
// steps
var stepsRow = new UI.Row();
var steps = new UI.Integer( options.steps ).onChange( update ).setRange( 1, Infinity );
stepsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setWidth( '90px' ) );
stepsRow.add( steps );
container.add( stepsRow );
// depth
var depthRow = new UI.Row();
var depth = new UI.Number( options.depth ).onChange( update ).setRange( 1, Infinity );
depthRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setWidth( '90px' ) );
depthRow.add( depth );
container.add( depthRow );
// enabled
var enabledRow = new UI.Row();
var enabled = new UI.Checkbox( options.bevelEnabled ).onChange( update );
enabledRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setWidth( '90px' ) );
enabledRow.add( enabled );
container.add( enabledRow );
if ( options.bevelEnabled === true ) {
// thickness
var thicknessRow = new UI.Row();
var thickness = new UI.Number( options.bevelThickness ).onChange( update );
thicknessRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setWidth( '90px' ) );
thicknessRow.add( thickness );
container.add( thicknessRow );
// size
var sizeRow = new UI.Row();
var size = new UI.Number( options.bevelSize ).onChange( update );
sizeRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setWidth( '90px' ) );
sizeRow.add( size );
container.add( sizeRow );
// offset
var offsetRow = new UI.Row();
var offset = new UI.Number( options.bevelOffset ).onChange( update );
offsetRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setWidth( '90px' ) );
offsetRow.add( offset );
container.add( offsetRow );
// segments
var segmentsRow = new UI.Row();
var segments = new UI.Integer( options.bevelSegments ).onChange( update ).setRange( 0, Infinity );
segmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setWidth( '90px' ) );
segmentsRow.add( segments );
container.add( segmentsRow );
}
var button = new UI.Button( strings.getKey( 'sidebar/geometry/extrude_geometry/shape' ) ).onClick( toShape ).setWidth( '90px' ).setMarginLeft( '90px' );
container.add( button );
//
function update() {
editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ](
parameters.shapes,
{
curveSegments: curveSegments.getValue(),
steps: steps.getValue(),
depth: depth.getValue(),
bevelEnabled: enabled.getValue(),
bevelThickness: thickness !== undefined ? thickness.getValue() : options.bevelThickness,
bevelSize: size !== undefined ? size.getValue() : options.bevelSize,
bevelOffset: offset !== undefined ? offset.getValue() : options.bevelOffset,
bevelSegments: segments !== undefined ? segments.getValue() : options.bevelSegments
}
) ) );
}
function toShape() {
editor.execute( new SetGeometryCommand( object, new THREE.ShapeBufferGeometry(
parameters.shapes,
options.curveSegments
) ) );
}
return container;
};
Sidebar.Geometry.ExtrudeBufferGeometry = Sidebar.Geometry.ExtrudeGeometry;
/**
* @author Temdog007 / http://github.com/Temdog007
*/
Sidebar.Geometry.ShapeGeometry = function ( editor, object ) {
var strings = editor.strings;
var signals = editor.signals;
var container = new UI.Row();
var geometry = object.geometry;
var parameters = geometry.parameters;
// curveSegments
var curveSegmentsRow = new UI.Row();
var curveSegments = new UI.Integer( parameters.curveSegments || 12 ).onChange( changeShape ).setRange( 1, Infinity );
curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/shape_geometry/curveSegments' ) ).setWidth( '90px' ) );
curveSegmentsRow.add( curveSegments );
container.add( curveSegmentsRow );
// to extrude
var button = new UI.Button( strings.getKey( 'sidebar/geometry/shape_geometry/extrude' ) ).onClick( toExtrude ).setWidth( '90px' ).setMarginLeft( '90px' );
container.add( button );
//
function changeShape() {
editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ](
parameters.shapes,
curveSegments.getValue()
) ) );
}
function toExtrude() {
editor.execute( new SetGeometryCommand( object, new THREE.ExtrudeBufferGeometry(
parameters.shapes, {
curveSegments: curveSegments.getValue()
}
) ) );
}
return container;
};
Sidebar.Geometry.ShapeBufferGeometry = Sidebar.Geometry.ShapeGeometry;
......@@ -135,6 +135,16 @@ var Strings = function ( config ) {
'sidebar/geometry/cylinder_geometry/heightsegments': 'Height segments',
'sidebar/geometry/cylinder_geometry/openended': 'Open ended',
'sidebar/geometry/extrude_geometry/curveSegments': 'Curve Segments',
'sidebar/geometry/extrude_geometry/steps': 'Steps',
'sidebar/geometry/extrude_geometry/depth': 'Depth',
'sidebar/geometry/extrude_geometry/bevelEnabled': 'Bevel?',
'sidebar/geometry/extrude_geometry/bevelThickness': 'Thickness',
'sidebar/geometry/extrude_geometry/bevelSize': 'Size',
'sidebar/geometry/extrude_geometry/bevelOffset': 'Offset',
'sidebar/geometry/extrude_geometry/bevelSegments': 'Segments',
'sidebar/geometry/extrude_geometry/shape': 'Convert to Shape',
'sidebar/geometry/geometry/vertices': 'Vertices',
'sidebar/geometry/geometry/faces': 'Faces',
......@@ -164,6 +174,9 @@ var Strings = function ( config ) {
'sidebar/geometry/ring_geometry/thetastart': 'Theta start',
'sidebar/geometry/ring_geometry/thetalength': 'Theta length',
'sidebar/geometry/shape_geometry/curveSegments': 'Curve Segments',
'sidebar/geometry/shape_geometry/extrude': 'Extrude',
'sidebar/geometry/sphere_geometry/radius': 'Radius',
'sidebar/geometry/sphere_geometry/widthsegments': 'Width segments',
'sidebar/geometry/sphere_geometry/heightsegments': 'Height segments',
......
......@@ -23,5 +23,5 @@ export class GLTFLoader {
setResourcePath(path: string) : GLTFLoader;
setCrossOrigin(value: string): void;
setDRACOLoader(dracoLoader: object): void;
parse(data: ArrayBuffer, path: string, onLoad: (gltf: GLTF) => void, onError?: (event: ErrorEvent) => void) : void;
parse(data: ArrayBuffer | string, path: string, onLoad: (gltf: GLTF) => void, onError?: (event: ErrorEvent) => void) : void;
}
......@@ -633,7 +633,6 @@
var currentRenderTarget = gpuCompute.getCurrentRenderTarget( heightmapVariable );
readWaterLevelShader.uniforms[ "texture" ].value = currentRenderTarget.texture;
var gl = renderer.context;
for ( var i = 0; i < NUM_SPHERES; i ++ ) {
......@@ -646,11 +645,9 @@
var v = 1 - ( 0.5 * sphere.position.z / BOUNDS_HALF + 0.5 );
readWaterLevelShader.uniforms[ "point1" ].value.set( u, v );
gpuCompute.doRenderTarget( readWaterLevelShader, readWaterLevelRenderTarget );
var previousRenderTarget = renderer.getRenderTarget();
renderer.setRenderTarget( readWaterLevelRenderTarget );
gl.readPixels( 0, 0, 4, 1, gl.RGBA, gl.UNSIGNED_BYTE, readWaterLevelImage );
renderer.readRenderTargetPixels( readWaterLevelRenderTarget, 0, 0, 4, 1, readWaterLevelImage );
var pixels = new Float32Array( readWaterLevelImage.buffer );
renderer.setRenderTarget( previousRenderTarget );
// Get orientation
waterNormal.set( pixels[ 1 ], 0, - pixels[ 2 ] );
......
......@@ -33,6 +33,18 @@ InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry
return new this.constructor().copy( this );
},
toJSON: function () {
var data = BufferGeometry.prototype.toJSON.call( this );
data.maxInstancedCount = this.maxInstancedCount;
data.isInstancedBufferGeometry = true;
return data;
}
} );
......
......@@ -4,6 +4,8 @@ import { BufferAttribute } from '../core/BufferAttribute.js';
import { BufferGeometry } from '../core/BufferGeometry.js';
import { FileLoader } from './FileLoader.js';
import { DefaultLoadingManager } from './LoadingManager.js';
import { InstancedBufferGeometry } from '../core/InstancedBufferGeometry.js';
import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js';
/**
* @author mrdoob / http://mrdoob.com/
......@@ -33,7 +35,7 @@ Object.assign( BufferGeometryLoader.prototype, {
parse: function ( json ) {
var geometry = new BufferGeometry();
var geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry();
var index = json.data.index;
......@@ -50,8 +52,8 @@ Object.assign( BufferGeometryLoader.prototype, {
var attribute = attributes[ key ];
var typedArray = new TYPED_ARRAYS[ attribute.type ]( attribute.array );
var bufferAttribute = new BufferAttribute( typedArray, attribute.itemSize, attribute.normalized );
var bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;
var bufferAttribute = new bufferAttributeConstr( typedArray, attribute.itemSize, attribute.normalized );
if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name;
geometry.addAttribute( key, bufferAttribute );
......
......@@ -430,6 +430,7 @@ Object.assign( ObjectLoader.prototype, {
break;
case 'BufferGeometry':
case 'InstancedBufferGeometry':
geometry = bufferGeometryLoader.parse( data );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册