Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run build-examples #21588

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 56 additions & 61 deletions examples/js/WebGL.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,84 @@
THREE.WEBGL = {
( function () {

isWebGLAvailable: function () {
var WEBGL = {
isWebGLAvailable: function () {

try {
try {

var canvas = document.createElement( 'canvas' );
return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
var canvas = document.createElement( 'canvas' );
return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );

} catch ( e ) {
} catch ( e ) {

return false;
return false;

}

},

isWebGL2Available: function () {

try {

var canvas = document.createElement( 'canvas' );
return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
}

} catch ( e ) {
},
isWebGL2Available: function () {

return false;
try {

}

},
var canvas = document.createElement( 'canvas' );
return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );

getWebGLErrorMessage: function () {
} catch ( e ) {

return this.getErrorMessage( 1 );
return false;

},
}

getWebGL2ErrorMessage: function () {
},
getWebGLErrorMessage: function () {

return this.getErrorMessage( 2 );
return this.getErrorMessage( 1 );

},
},
getWebGL2ErrorMessage: function () {

getErrorMessage: function ( version ) {
return this.getErrorMessage( 2 );

var names = {
1: 'WebGL',
2: 'WebGL 2'
};
},
getErrorMessage: function ( version ) {

var contexts = {
1: window.WebGLRenderingContext,
2: window.WebGL2RenderingContext
};
var names = {
1: 'WebGL',
2: 'WebGL 2'
};
var contexts = {
1: window.WebGLRenderingContext,
2: window.WebGL2RenderingContext
};
var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
var element = document.createElement( 'div' );
element.id = 'webglmessage';
element.style.fontFamily = 'monospace';
element.style.fontSize = '13px';
element.style.fontWeight = 'normal';
element.style.textAlign = 'center';
element.style.background = '#fff';
element.style.color = '#000';
element.style.padding = '1.5em';
element.style.width = '400px';
element.style.margin = '5em auto 0';

var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
if ( contexts[ version ] ) {

var element = document.createElement( 'div' );
element.id = 'webglmessage';
element.style.fontFamily = 'monospace';
element.style.fontSize = '13px';
element.style.fontWeight = 'normal';
element.style.textAlign = 'center';
element.style.background = '#fff';
element.style.color = '#000';
element.style.padding = '1.5em';
element.style.width = '400px';
element.style.margin = '5em auto 0';
message = message.replace( '$0', 'graphics card' );

if ( contexts[ version ] ) {
} else {

message = message.replace( '$0', 'graphics card' );
message = message.replace( '$0', 'browser' );

} else {
}

message = message.replace( '$0', 'browser' );
message = message.replace( '$1', names[ version ] );
element.innerHTML = message;
return element;

}
};

message = message.replace( '$1', names[ version ] );

element.innerHTML = message;

return element;

}
THREE.WEBGL = WEBGL;

};
} )();
137 changes: 64 additions & 73 deletions examples/js/animation/AnimationClipCreator.js
Original file line number Diff line number Diff line change
@@ -1,106 +1,97 @@
THREE.AnimationClipCreator = function () {};
( function () {

THREE.AnimationClipCreator.CreateRotationAnimation = function ( period, axis ) {
var AnimationClipCreator = function () {};

var times = [ 0, period ], values = [ 0, 360 ];
AnimationClipCreator.CreateRotationAnimation = function ( period, axis ) {

axis = axis || 'x';
var trackName = '.rotation[' + axis + ']';
var times = [ 0, period ],
values = [ 0, 360 ];
axis = axis || 'x';
var trackName = '.rotation[' + axis + ']';
var track = new THREE.NumberKeyframeTrack( trackName, times, values );
return new THREE.AnimationClip( null, period, [ track ] );

var track = new THREE.NumberKeyframeTrack( trackName, times, values );
};

return new THREE.AnimationClip( null, period, [ track ] );
AnimationClipCreator.CreateScaleAxisAnimation = function ( period, axis ) {

};
var times = [ 0, period ],
values = [ 0, 1 ];
axis = axis || 'x';
var trackName = '.scale[' + axis + ']';
var track = new THREE.NumberKeyframeTrack( trackName, times, values );
return new THREE.AnimationClip( null, period, [ track ] );

THREE.AnimationClipCreator.CreateScaleAxisAnimation = function ( period, axis ) {
};

var times = [ 0, period ], values = [ 0, 1 ];
AnimationClipCreator.CreateShakeAnimation = function ( duration, shakeScale ) {

axis = axis || 'x';
var trackName = '.scale[' + axis + ']';
var times = [],
values = [],
tmp = new THREE.Vector3();

var track = new THREE.NumberKeyframeTrack( trackName, times, values );
for ( var i = 0; i < duration * 10; i ++ ) {

return new THREE.AnimationClip( null, period, [ track ] );
times.push( i / 10 );
tmp.set( Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0 ).multiply( shakeScale ).toArray( values, values.length );

};
}

THREE.AnimationClipCreator.CreateShakeAnimation = function ( duration, shakeScale ) {
var trackName = '.position';
var track = new THREE.VectorKeyframeTrack( trackName, times, values );
return new THREE.AnimationClip( null, duration, [ track ] );

var times = [], values = [], tmp = new THREE.Vector3();
};

for ( var i = 0; i < duration * 10; i ++ ) {
AnimationClipCreator.CreatePulsationAnimation = function ( duration, pulseScale ) {

times.push( i / 10 );
var times = [],
values = [],
tmp = new THREE.Vector3();

tmp.set( Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0 ).
multiply( shakeScale ).
toArray( values, values.length );
for ( var i = 0; i < duration * 10; i ++ ) {

}
times.push( i / 10 );
var scaleFactor = Math.random() * pulseScale;
tmp.set( scaleFactor, scaleFactor, scaleFactor ).toArray( values, values.length );

var trackName = '.position';
}

var track = new THREE.VectorKeyframeTrack( trackName, times, values );
var trackName = '.scale';
var track = new THREE.VectorKeyframeTrack( trackName, times, values );
return new THREE.AnimationClip( null, duration, [ track ] );

return new THREE.AnimationClip( null, duration, [ track ] );
};

};
AnimationClipCreator.CreateVisibilityAnimation = function ( duration ) {

var times = [ 0, duration / 2, duration ],
values = [ true, false, true ];
var trackName = '.visible';
var track = new THREE.BooleanKeyframeTrack( trackName, times, values );
return new THREE.AnimationClip( null, duration, [ track ] );

THREE.AnimationClipCreator.CreatePulsationAnimation = function ( duration, pulseScale ) {
};

var times = [], values = [], tmp = new THREE.Vector3();
AnimationClipCreator.CreateMaterialColorAnimation = function ( duration, colors ) {

for ( var i = 0; i < duration * 10; i ++ ) {
var times = [],
values = [],
timeStep = duration / colors.length;

times.push( i / 10 );
for ( var i = 0; i <= colors.length; i ++ ) {

var scaleFactor = Math.random() * pulseScale;
tmp.set( scaleFactor, scaleFactor, scaleFactor ).
toArray( values, values.length );
times.push( i * timeStep );
values.push( colors[ i % colors.length ] );

}
}

var trackName = '.scale';
var trackName = '.material[0].color';
var track = new THREE.ColorKeyframeTrack( trackName, times, values );
return new THREE.AnimationClip( null, duration, [ track ] );

var track = new THREE.VectorKeyframeTrack( trackName, times, values );
};

return new THREE.AnimationClip( null, duration, [ track ] );
THREE.AnimationClipCreator = AnimationClipCreator;

};


THREE.AnimationClipCreator.CreateVisibilityAnimation = function ( duration ) {

var times = [ 0, duration / 2, duration ], values = [ true, false, true ];

var trackName = '.visible';

var track = new THREE.BooleanKeyframeTrack( trackName, times, values );

return new THREE.AnimationClip( null, duration, [ track ] );

};


THREE.AnimationClipCreator.CreateMaterialColorAnimation = function ( duration, colors ) {

var times = [], values = [],
timeStep = duration / colors.length;

for ( var i = 0; i <= colors.length; i ++ ) {

times.push( i * timeStep );
values.push( colors[ i % colors.length ] );

}

var trackName = '.material[0].color';

var track = new THREE.ColorKeyframeTrack( trackName, times, values );

return new THREE.AnimationClip( null, duration, [ track ] );

};
} )();
Loading