Skip to content

Commit

Permalink
merge dev -> mrdoobgh-9489-alt
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 16, 2016
2 parents dbe792a + 3423b6d commit 2cd2724
Show file tree
Hide file tree
Showing 223 changed files with 26,765 additions and 25,370 deletions.
49,645 changes: 24,862 additions & 24,783 deletions build/three.js

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions build/three.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/core/BufferAttribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3>[property:Integer itemSize]</h3>
attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
</div>

<h3>[property:Integer length]</h3>
<h3>[property:Integer count]</h3>
<div>
Gives the total number of elements in the array.
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/introduction/Creating-a-scene.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h2>Creating the scene</h2>

<div>In addition to creating the renderer instance, we also need to set the size at which we want it to render our app. It's a good idea to use the width and height of the area we want to fill with our app - in this case, the width and height of the browser window. For performance intensive apps, you can also give <strong>setSize</strong> smaller values, like <strong>window.innerWidth/2</strong> and <strong>window.innerHeight/2</strong>, which will make the app render at half size.</div>

<div>If you wish to keep the size of your app but render it at a lower resolution, you can do so by calling <strong>setSize</strong> with false as <strong>updateStyle</strong>. For example, <strong>setSize(window.innerWidth/2, window.innerHeight/2, false)</strong> will render your app at half resolution, given that your &lt;canvas&gt; has 100% width and height.</div>
<div>If you wish to keep the size of your app but render it at a lower resolution, you can do so by calling <strong>setSize</strong> with false as <strong>updateStyle</strong> (the third arugment). For example, <strong>setSize(window.innerWidth/2, window.innerHeight/2, false)</strong> will render your app at half resolution, given that your &lt;canvas&gt; has 100% width and height.</div>

<div>Last but not least, we add the <strong>renderer</strong> element to our HTML document. This is a &lt;canvas&gt; element the renderer uses to display the scene to us.</div>

Expand Down
3 changes: 3 additions & 0 deletions editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<script src="js/Toolbar.js"></script>
<script src="js/Viewport.js"></script>
<script src="js/Viewport.Info.js"></script>

<script src="js/Command.js"></script>
<script src="js/commands/AddObjectCommand.js"></script>
<script src="js/commands/RemoveObjectCommand.js"></script>
Expand Down Expand Up @@ -253,6 +254,8 @@
signals.objectChanged.add( saveState );
signals.objectRemoved.add( saveState );
signals.materialChanged.add( saveState );
signals.sceneBackgroundChanged.add( saveState );
signals.sceneFogChanged.add( saveState );
signals.sceneGraphChanged.add( saveState );
signals.scriptChanged.add( saveState );
signals.historyChanged.add( saveState );
Expand Down
10 changes: 7 additions & 3 deletions editor/js/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var Editor = function () {
spaceChanged: new Signal(),
rendererChanged: new Signal(),

sceneBackgroundChanged: new Signal(),
sceneFogChanged: new Signal(),
sceneGraphChanged: new Signal(),

cameraChanged: new Signal(),
Expand All @@ -69,9 +71,6 @@ var Editor = function () {
scriptChanged: new Signal(),
scriptRemoved: new Signal(),

fogTypeChanged: new Signal(),
fogColorChanged: new Signal(),
fogParametersChanged: new Signal(),
windowResize: new Signal(),

showGridChanged: new Signal(),
Expand All @@ -90,6 +89,7 @@ var Editor = function () {

this.scene = new THREE.Scene();
this.scene.name = 'Scene';
this.scene.background = new THREE.Color( 0xaaaaaa );

this.sceneHelpers = new THREE.Scene();

Expand Down Expand Up @@ -120,6 +120,10 @@ Editor.prototype = {

this.scene.uuid = scene.uuid;
this.scene.name = scene.name;

if ( scene.background !== null ) this.scene.background = scene.background.clone();
if ( scene.fog !== null ) this.scene.fog = scene.fog.clone();

this.scene.userData = JSON.parse( JSON.stringify( scene.userData ) );

// avoid render per object
Expand Down
59 changes: 29 additions & 30 deletions editor/js/Sidebar.Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,34 @@ Sidebar.Scene = function ( editor ) {
container.add( outliner );
container.add( new UI.Break() );

/*
// background

var backgroundRow = new UI.Row();
var background = new UI.Select().setOptions( {
function onBackgroundChanged() {

'None': 'None',
'Color': 'Color',
'Texture': 'Texture'
signals.sceneBackgroundChanged.dispatch( backgroundColor.getHexValue() );

} ).setWidth( '150px' );
background.onChange( function () {} );
}

var backgroundRow = new UI.Row();

var backgroundColor = new UI.Color().setValue( '#aaaaaa' ).onChange( onBackgroundChanged );

backgroundRow.add( new UI.Text( 'Background' ).setWidth( '90px' ) );
backgroundRow.add( background );
backgroundRow.add( backgroundColor );

container.add( backgroundRow );
*/

// fog

function updateFogParameters() {

var near = fogNear.getValue();
var far = fogFar.getValue();
var density = fogDensity.getValue();
function onFogChanged() {

signals.fogParametersChanged.dispatch( near, far, density );
signals.sceneFogChanged.dispatch(
fogType.getValue(),
fogColor.getHexValue(),
fogNear.getValue(),
fogFar.getValue(),
fogDensity.getValue()
);

}

Expand All @@ -117,10 +117,7 @@ Sidebar.Scene = function ( editor ) {
} ).setWidth( '150px' );
fogType.onChange( function () {

var type = fogType.getValue();

signals.fogTypeChanged.dispatch( type );

onFogChanged();
refreshFogUI();

} );
Expand All @@ -138,31 +135,27 @@ Sidebar.Scene = function ( editor ) {
container.add( fogPropertiesRow );

var fogColor = new UI.Color().setValue( '#aaaaaa' );
fogColor.onChange( function () {

signals.fogColorChanged.dispatch( fogColor.getHexValue() );

} );
fogColor.onChange( onFogChanged );
fogPropertiesRow.add( fogColor );

// fog near

var fogNear = new UI.Number( 0.1 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( updateFogParameters );
var fogNear = new UI.Number( 0.1 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( onFogChanged );
fogPropertiesRow.add( fogNear );

// fog far

var fogFar = new UI.Number( 100 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( updateFogParameters );
var fogFar = new UI.Number( 50 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( onFogChanged );
fogPropertiesRow.add( fogFar );

// fog density

var fogDensity = new UI.Number( 0.00025 ).setWidth( '40px' ).setRange( 0, 0.1 ).setPrecision( 5 ).onChange( updateFogParameters );
var fogDensity = new UI.Number( 0.05 ).setWidth( '40px' ).setRange( 0, 0.1 ).setPrecision( 3 ).onChange( onFogChanged );
fogPropertiesRow.add( fogDensity );

//

var refreshUI = function () {
function refreshUI() {

var camera = editor.camera;
var scene = editor.scene;
Expand Down Expand Up @@ -196,6 +189,12 @@ Sidebar.Scene = function ( editor ) {

}

if ( scene.background ) {

backgroundColor.setHexValue( scene.background.getHex() );

}

if ( scene.fog ) {

fogColor.setHexValue( scene.fog.color.getHex() );
Expand All @@ -221,7 +220,7 @@ Sidebar.Scene = function ( editor ) {

refreshFogUI();

};
}

function refreshFogUI() {

Expand Down
86 changes: 30 additions & 56 deletions editor/js/Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,6 @@ var Viewport = function ( editor ) {

sceneHelpers.add( transformControls );

// fog

var oldFogType = "None";
var oldFogColor = 0xaaaaaa;
var oldFogNear = 1;
var oldFogFar = 5000;
var oldFogDensity = 0.00025;

// object picking

var raycaster = new THREE.Raycaster();
Expand Down Expand Up @@ -297,8 +289,6 @@ var Viewport = function ( editor ) {

} );

var clearColor;

signals.themeChanged.add( function ( value ) {

switch ( value ) {
Expand All @@ -307,19 +297,15 @@ var Viewport = function ( editor ) {
sceneHelpers.remove( grid );
grid = new THREE.GridHelper( 30, 60, 0x444444, 0x888888 );
sceneHelpers.add( grid );
clearColor = 0xaaaaaa;
break;
case 'css/dark.css':
sceneHelpers.remove( grid );
grid = new THREE.GridHelper( 30, 60, 0xbbbbbb, 0x888888 );
sceneHelpers.add( grid );
clearColor = 0x333333;
break;

}

renderer.setClearColor( clearColor );

render();

} );
Expand Down Expand Up @@ -354,7 +340,6 @@ var Viewport = function ( editor ) {

renderer.autoClear = false;
renderer.autoUpdateScene = false;
renderer.setClearColor( clearColor );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( container.dom.offsetWidth, container.dom.offsetHeight );

Expand Down Expand Up @@ -496,53 +481,58 @@ var Viewport = function ( editor ) {

} );

signals.fogTypeChanged.add( function ( fogType ) {
// fog

signals.sceneBackgroundChanged.add( function ( backgroundColor ) {

scene.background.setHex( backgroundColor );

if ( fogType !== oldFogType ) {
render();

if ( fogType === "None" ) {
} );

scene.fog = null;
var currentFogType = null;

} else if ( fogType === "Fog" ) {
signals.sceneFogChanged.add( function ( fogType, fogColor, fogNear, fogFar, fogDensity ) {

scene.fog = new THREE.Fog( oldFogColor, oldFogNear, oldFogFar );
if ( currentFogType !== fogType ) {

} else if ( fogType === "FogExp2" ) {
switch ( fogType ) {

scene.fog = new THREE.FogExp2( oldFogColor, oldFogDensity );
case 'None':
scene.fog = null;
break;
case 'Fog':
scene.fog = new THREE.Fog();
break;
case 'FogExp2':
scene.fog = new THREE.FogExp2();
break;

}

oldFogType = fogType;
currentFogType = fogType;

}

render();
if ( scene.fog instanceof THREE.Fog ) {

} );
scene.fog.color.setHex( fogColor );
scene.fog.near = fogNear;
scene.fog.far = fogFar;

signals.fogColorChanged.add( function ( fogColor ) {
} else if ( scene.fog instanceof THREE.FogExp2 ) {

oldFogColor = fogColor;
scene.fog.color.setHex( fogColor );
scene.fog.density = fogDensity;

updateFog( scene );
}

render();

} );

signals.fogParametersChanged.add( function ( near, far, density ) {

oldFogNear = near;
oldFogFar = far;
oldFogDensity = density;

updateFog( scene );

render();

} );
//

signals.windowResize.add( function () {

Expand All @@ -569,20 +559,6 @@ var Viewport = function ( editor ) {

//

function updateFog( root ) {

if ( root.fog ) {

root.fog.color.setHex( oldFogColor );

if ( root.fog.near !== undefined ) root.fog.near = oldFogNear;
if ( root.fog.far !== undefined ) root.fog.far = oldFogFar;
if ( root.fog.density !== undefined ) root.fog.density = oldFogDensity;

}

}

function animate() {

requestAnimationFrame( animate );
Expand Down Expand Up @@ -628,14 +604,12 @@ var Viewport = function ( editor ) {
vrControls.update();

camera.updateMatrixWorld();
renderer.clear();

vrEffect.render( scene, vrCamera );
vrEffect.render( sceneHelpers, vrCamera );

} else {

renderer.clear();
renderer.render( scene, camera );

if ( renderer instanceof THREE.RaytracingRenderer === false ) {
Expand Down
1 change: 1 addition & 0 deletions examples/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ var files = {
"webgl_physics_rope",
"webgl_physics_cloth",
"webgl_physics_volume",
"webgl_physics_convex_break",
"webgl_points_billboards",
"webgl_points_billboards_colors",
"webgl_points_dynamic",
Expand Down
Loading

0 comments on commit 2cd2724

Please sign in to comment.