提交 3e09e8de 编写于 作者: K Kyle Larson 提交者: GitHub

Merge pull request #1 from Kyle-Larson/FBX-Material-Application

FBX loader fix
{
"name": "three.js",
"homepage": "http://threejs.org/",
"description": "JavaScript 3D library",
"main": "build/three.js",
"keywords": [
"three",
"threejs",
"three.js",
"3D",
"webgl"
],
"license": "MIT",
"ignore": [
"**/.*",
"*.md",
"/docs",
"/editor",
"/examples/*",
"!/examples/js",
"/src",
"/test",
"/utils",
"/LICENSE"
]
}
......@@ -4971,7 +4971,7 @@
var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n";
......@@ -5113,7 +5113,7 @@
var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
var meshphysical_vert = "#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n";
......@@ -7765,6 +7765,37 @@
},
setFromBufferAttribute: function ( attribute ) {
var minX = + Infinity;
var minY = + Infinity;
var minZ = + Infinity;
var maxX = - Infinity;
var maxY = - Infinity;
var maxZ = - Infinity;
for ( var i = 0, l = attribute.count; i < l; i ++ ) {
var x = attribute.getX( i );
var y = attribute.getY( i );
var z = attribute.getZ( i );
if ( x < minX ) minX = x;
if ( y < minY ) minY = y;
if ( z < minZ ) minZ = z;
if ( x > maxX ) maxX = x;
if ( y > maxY ) maxY = y;
if ( z > maxZ ) maxZ = z;
}
this.min.set( minX, minY, minZ );
this.max.set( maxX, maxY, maxZ );
},
setFromPoints: function ( points ) {
this.makeEmpty();
......@@ -14252,11 +14283,11 @@
}
var positions = this.attributes.position.array;
var position = this.attributes.position;
if ( positions !== undefined ) {
if ( position !== undefined ) {
this.boundingBox.setFromArray( positions );
this.boundingBox.setFromBufferAttribute( position );
} else {
......@@ -14285,14 +14316,13 @@
}
var positions = this.attributes.position;
var position = this.attributes.position;
if ( positions ) {
if ( position ) {
var array = positions.array;
var center = this.boundingSphere.center;
box.setFromArray( array );
box.setFromBufferAttribute( position );
box.getCenter( center );
// hoping to find a boundingSphere with a radius smaller than the
......@@ -14300,9 +14330,11 @@
var maxRadiusSq = 0;
for ( var i = 0, il = array.length; i < il; i += 3 ) {
for ( var i = 0, il = position.count; i < il; i ++ ) {
vector.fromArray( array, i );
vector.x = position.getX( i );
vector.y = position.getY( i );
vector.z = position.getZ( i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
}
......@@ -15779,11 +15811,15 @@
type = gl.UNSIGNED_INT;
size = 4;
} else {
} else if ( index.array instanceof Uint16Array ) {
type = gl.UNSIGNED_SHORT;
size = 2;
} else {
type = gl.UNSIGNED_BYTE;
size = 1;
}
}
......@@ -28107,7 +28143,7 @@
this.type = 'MultiMaterial';
this.materials = materials instanceof Array ? materials : [];
this.materials = Array.isArray( materials ) ? materials : [];
this.visible = true;
......@@ -36737,7 +36773,7 @@
// scene:helium_balloon_model:helium_balloon_model.position
// created and tested via https://regex101.com/#javascript
var re = /^((?:\w+[\/:])*)(\w+)?(?:\.(\w+)(?:\[(.+)\])?)?\.(\w+)(?:\[(.+)\])?$/;
var re = /^((?:[\w-]+[\/:])*)([\w-]+)?(?:\.([\w-]+)(?:\[(.+)\])?)?\.([\w-]+)(?:\[(.+)\])?$/;
var matches = re.exec( trackName );
if ( ! matches ) {
......
此差异已折叠。
......@@ -4965,7 +4965,7 @@ var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n retur
var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n";
......@@ -5107,7 +5107,7 @@ var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissiv
var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
var meshphysical_vert = "#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n";
......@@ -7759,6 +7759,37 @@ Box3.prototype = {
},
setFromBufferAttribute: function ( attribute ) {
var minX = + Infinity;
var minY = + Infinity;
var minZ = + Infinity;
var maxX = - Infinity;
var maxY = - Infinity;
var maxZ = - Infinity;
for ( var i = 0, l = attribute.count; i < l; i ++ ) {
var x = attribute.getX( i );
var y = attribute.getY( i );
var z = attribute.getZ( i );
if ( x < minX ) minX = x;
if ( y < minY ) minY = y;
if ( z < minZ ) minZ = z;
if ( x > maxX ) maxX = x;
if ( y > maxY ) maxY = y;
if ( z > maxZ ) maxZ = z;
}
this.min.set( minX, minY, minZ );
this.max.set( maxX, maxY, maxZ );
},
setFromPoints: function ( points ) {
this.makeEmpty();
......@@ -14246,11 +14277,11 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
}
var positions = this.attributes.position.array;
var position = this.attributes.position;
if ( positions !== undefined ) {
if ( position !== undefined ) {
this.boundingBox.setFromArray( positions );
this.boundingBox.setFromBufferAttribute( position );
} else {
......@@ -14279,14 +14310,13 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
}
var positions = this.attributes.position;
var position = this.attributes.position;
if ( positions ) {
if ( position ) {
var array = positions.array;
var center = this.boundingSphere.center;
box.setFromArray( array );
box.setFromBufferAttribute( position );
box.getCenter( center );
// hoping to find a boundingSphere with a radius smaller than the
......@@ -14294,9 +14324,11 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
var maxRadiusSq = 0;
for ( var i = 0, il = array.length; i < il; i += 3 ) {
for ( var i = 0, il = position.count; i < il; i ++ ) {
vector.fromArray( array, i );
vector.x = position.getX( i );
vector.y = position.getY( i );
vector.z = position.getZ( i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
}
......@@ -15773,11 +15805,15 @@ function WebGLIndexedBufferRenderer( gl, extensions, infoRender ) {
type = gl.UNSIGNED_INT;
size = 4;
} else {
} else if ( index.array instanceof Uint16Array ) {
type = gl.UNSIGNED_SHORT;
size = 2;
} else {
type = gl.UNSIGNED_BYTE;
size = 1;
}
}
......@@ -28101,7 +28137,7 @@ function MultiMaterial( materials ) {
this.type = 'MultiMaterial';
this.materials = materials instanceof Array ? materials : [];
this.materials = Array.isArray( materials ) ? materials : [];
this.visible = true;
......@@ -36731,7 +36767,7 @@ PropertyBinding.parseTrackName = function( trackName ) {
// scene:helium_balloon_model:helium_balloon_model.position
// created and tested via https://regex101.com/#javascript
var re = /^((?:\w+[\/:])*)(\w+)?(?:\.(\w+)(?:\[(.+)\])?)?\.(\w+)(?:\[(.+)\])?$/;
var re = /^((?:[\w-]+[\/:])*)([\w-]+)?(?:\.([\w-]+)(?:\[(.+)\])?)?\.([\w-]+)(?:\[(.+)\])?$/;
var matches = re.exec( trackName );
if ( ! matches ) {
......
......@@ -93,6 +93,22 @@
Determines whether or not this box intersects *plane*.
</div>
<h3>[method:Box3 setFromArray]( [page:Array array] ) [page:Box3 this]</h3>
<div>
array -- An array of position data that the resulting box will envelop.
</div>
<div>
Sets the upper and lower bounds of this box to include all of the data in *array*.
</div>
<h3>[method:Box3 setFromBufferAttribute]( [page:BufferAttribute attribute] ) [page:Box3 this]</h3>
<div>
buffer -- A buffer attribute of position data that the resulting box will envelop.
</div>
<div>
Sets the upper and lower bounds of this box to include all of the data in *attribute*.
</div>
<h3>[method:Box3 setFromPoints]( [page:Array points] ) [page:Box3 this]</h3>
<div>
points -- Set of points that the resulting box will envelop.
......@@ -101,6 +117,16 @@
Sets the upper and lower bounds of this box to include all of the points in *points*.
</div>
<h3>[method:Box3 setFromCenterAndSize]( [page:Vector3 center], [page:Vector3 size] ) [page:Box3 this]</h3>
<div>
center -- Desired center position of the box. <br>
size -- Desired x, y and z dimensions of the box.
</div>
<div>
Centers this box on *center* and sets this box's width, height and depth to the values specified <br>
in *size*.
</div>
<h3>[method:Box3 setFromObject]( [page:Object3D object] ) [page:Box3 this]</h3>
<div>
object -- [page:Object3D] to compute the bounding box for.
......@@ -262,16 +288,6 @@
If the point lies inside of this box, the distance will be 0.
</div>
<h3>[method:Box3 setFromCenterAndSize]( [page:Vector3 center], [page:Vector3 size] ) [page:Box3 this]</h3>
<div>
center -- Desired center position of the box. <br>
size -- Desired x, y and z dimensions of the box.
</div>
<div>
Centers this box on *center* and sets this box's width, height and depth to the values specified <br>
in *size*.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -368,8 +368,6 @@ var Viewport = function ( editor ) {
} );
var saveTimeout;
signals.cameraChanged.add( function () {
render();
......@@ -381,7 +379,7 @@ var Viewport = function ( editor ) {
selectionBox.visible = false;
transformControls.detach();
if ( object !== null ) {
if ( object !== null && object !== scene ) {
box.setFromObject( object );
......
此差异已折叠。
......@@ -132,9 +132,7 @@ THREE.GLTFLoader = ( function () {
function GLTFShader( targetNode, allNodes ) {
var scope = this;
this.boundUniforms = {};
var boundUniforms = {};
// bind each uniform to its source node
......@@ -156,7 +154,7 @@ THREE.GLTFLoader = ( function () {
}
scope.boundUniforms[ uniformId ] = {
boundUniforms[ uniformId ] = {
semantic: uniform.semantic,
sourceNode: sourceNode,
targetNode: targetNode,
......@@ -167,6 +165,7 @@ THREE.GLTFLoader = ( function () {
}
this.boundUniforms = boundUniforms;
this._m4 = new THREE.Matrix4();
}
......@@ -360,7 +359,8 @@ THREE.GLTFLoader = ( function () {
};
var INTERPOLATION = {
LINEAR: THREE.InterpolateLinear
LINEAR: THREE.InterpolateLinear,
STEP: THREE.InterpolateDiscrete
};
/* UTILITY FUNCTIONS */
......@@ -614,6 +614,8 @@ THREE.GLTFLoader = ( function () {
GLTFParser.prototype.parse = function ( callback ) {
var json = this.json;
// Clear the loader cache
this.cache.removeAll();
......@@ -626,7 +628,7 @@ THREE.GLTFLoader = ( function () {
] ).then( function ( dependencies ) {
var scene = dependencies.scenes[ this.json.scene ];
var scene = dependencies.scenes[ json.scene ];
var cameras = [];
......@@ -647,33 +649,39 @@ THREE.GLTFLoader = ( function () {
callback( scene, cameras, animations );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadShaders = function () {
return _each( this.json.shaders, function ( shader ) {
var json = this.json;
var options = this.options;
return _each( json.shaders, function ( shader ) {
return new Promise( function ( resolve ) {
var loader = new THREE.FileLoader();
loader.responseType = 'text';
loader.load( resolveURL( shader.uri, this.options.path ), function ( shaderText ) {
loader.load( resolveURL( shader.uri, options.path ), function ( shaderText ) {
resolve( shaderText );
} );
}.bind( this ) );
} );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadBuffers = function () {
return _each( this.json.buffers, function ( buffer ) {
var json = this.json;
var options = this.options;
return _each( json.buffers, function ( buffer ) {
if ( buffer.type === 'arraybuffer' ) {
......@@ -681,29 +689,31 @@ THREE.GLTFLoader = ( function () {
var loader = new THREE.FileLoader();
loader.responseType = 'arraybuffer';
loader.load( resolveURL( buffer.uri, this.options.path ), function ( buffer ) {
loader.load( resolveURL( buffer.uri, options.path ), function ( buffer ) {
resolve( buffer );
} );
}.bind( this ) );
} );
}
}.bind( this ) );
} );
};
GLTFParser.prototype.loadBufferViews = function () {
var json = this.json;
return this._withDependencies( [
"buffers"
] ).then( function ( dependencies ) {
return _each( this.json.bufferViews, function ( bufferView ) {
return _each( json.bufferViews, function ( bufferView ) {
var arraybuffer = dependencies.buffers[ bufferView.buffer ];
......@@ -711,19 +721,21 @@ THREE.GLTFLoader = ( function () {
} );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadAccessors = function () {
var json = this.json;
return this._withDependencies( [
"bufferViews"
] ).then( function ( dependencies ) {
return _each( this.json.accessors, function ( accessor ) {
return _each( json.accessors, function ( accessor ) {
var arraybuffer = dependencies.bufferViews[ accessor.bufferView ];
var itemSize = WEBGL_TYPE_SIZES[ accessor.type ];
......@@ -754,19 +766,22 @@ THREE.GLTFLoader = ( function () {
} );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadTextures = function () {
return _each( this.json.textures, function ( texture ) {
var json = this.json;
var options = this.options;
return _each( json.textures, function ( texture ) {
if ( texture.source ) {
return new Promise( function ( resolve ) {
var source = this.json.images[ texture.source ];
var source = json.images[ texture.source ];
var textureLoader = THREE.Loader.Handlers.get( source.uri );
......@@ -776,15 +791,15 @@ THREE.GLTFLoader = ( function () {
}
textureLoader.crossOrigin = this.options.crossOrigin || false;
textureLoader.crossOrigin = options.crossOrigin || false;
textureLoader.load( resolveURL( source.uri, this.options.path ), function ( _texture ) {
textureLoader.load( resolveURL( source.uri, options.path ), function ( _texture ) {
_texture.flipY = false;
if ( texture.sampler ) {
var sampler = this.json.samplers[ texture.sampler ];
var sampler = json.samplers[ texture.sampler ];
_texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ];
_texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ];
......@@ -795,18 +810,24 @@ THREE.GLTFLoader = ( function () {
resolve( _texture );
}.bind( this ) );
}, undefined, function () {
}.bind( this ) );
resolve();
} );
} );
}
}.bind( this ) );
} );
};
GLTFParser.prototype.loadMaterials = function () {
var json = this.json;
return this._withDependencies( [
"shaders",
......@@ -814,7 +835,7 @@ THREE.GLTFLoader = ( function () {
] ).then( function ( dependencies ) {
return _each( this.json.materials, function ( material ) {
return _each( json.materials, function ( material ) {
var materialType;
var materialValues = {};
......@@ -826,9 +847,9 @@ THREE.GLTFLoader = ( function () {
khr_material = material.extensions.KHR_materials_common;
} else if ( this.json.extensions && this.json.extensions.KHR_materials_common ) {
} else if ( json.extensions && json.extensions.KHR_materials_common ) {
khr_material = this.json.extensions.KHR_materials_common;
khr_material = json.extensions.KHR_materials_common;
}
......@@ -877,11 +898,11 @@ THREE.GLTFLoader = ( function () {
materialType = DeferredShaderMaterial;
var technique = this.json.techniques[ material.technique ];
var technique = json.techniques[ material.technique ];
materialParams.uniforms = {};
var program = this.json.programs[ technique.program ];
var program = json.programs[ technique.program ];
if ( program ) {
......@@ -1086,14 +1107,16 @@ THREE.GLTFLoader = ( function () {
return _material;
}.bind( this ) );
} );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadMeshes = function () {
var json = this.json;
return this._withDependencies( [
"accessors",
......@@ -1101,7 +1124,7 @@ THREE.GLTFLoader = ( function () {
] ).then( function ( dependencies ) {
return _each( this.json.meshes, function ( mesh ) {
return _each( json.meshes, function ( mesh ) {
var group = new THREE.Object3D();
group.name = mesh.name;
......@@ -1192,13 +1215,15 @@ THREE.GLTFLoader = ( function () {
} );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadCameras = function () {
return _each( this.json.cameras, function ( camera ) {
var json = this.json;
return _each( json.cameras, function ( camera ) {
if ( camera.type == "perspective" && camera.perspective ) {
......@@ -1228,13 +1253,13 @@ THREE.GLTFLoader = ( function () {
}
}.bind( this ) );
} );
};
GLTFParser.prototype.loadSkins = function () {
var scope = this;
var json = this.json;
return this._withDependencies( [
......@@ -1242,7 +1267,7 @@ THREE.GLTFLoader = ( function () {
] ).then( function ( dependencies ) {
return _each( scope.json.skins, function ( skin ) {
return _each( json.skins, function ( skin ) {
var _skin = {
bindShapeMatrix: new THREE.Matrix4().fromArray( skin.bindShapeMatrix ),
......@@ -1260,7 +1285,7 @@ THREE.GLTFLoader = ( function () {
GLTFParser.prototype.loadAnimations = function () {
var scope = this;
var json = this.json;
return this._withDependencies( [
......@@ -1269,7 +1294,7 @@ THREE.GLTFLoader = ( function () {
] ).then( function ( dependencies ) {
return _each( scope.json.animations, function ( animation, animationId ) {
return _each( json.animations, function ( animation, animationId ) {
var interps = [];
......@@ -1318,7 +1343,10 @@ THREE.GLTFLoader = ( function () {
GLTFParser.prototype.loadNodes = function () {
return _each( this.json.nodes, function ( node ) {
var json = this.json;
var scope = this;
return _each( json.nodes, function ( node ) {
var matrix = new THREE.Matrix4();
......@@ -1368,9 +1396,9 @@ THREE.GLTFLoader = ( function () {
return _node;
}.bind( this ) ).then( function ( __nodes ) {
} ).then( function ( __nodes ) {
return this._withDependencies( [
return scope._withDependencies( [
"meshes",
"skins",
......@@ -1381,7 +1409,7 @@ THREE.GLTFLoader = ( function () {
return _each( __nodes, function ( _node, nodeId ) {
var node = this.json.nodes[ nodeId ];
var node = json.nodes[ nodeId ];
if ( node.meshes !== undefined ) {
......@@ -1435,10 +1463,26 @@ THREE.GLTFLoader = ( function () {
var bones = [];
var boneInverses = [];
var keys = Object.keys( __nodes );
for ( var i = 0, l = skinEntry.jointNames.length; i < l; i ++ ) {
var jointId = skinEntry.jointNames[ i ];
var jointNode = __nodes[ jointId ];
var jointNode;
for ( var j = 0, jl = keys.length; j < jl; j ++ ) {
var n = __nodes[ keys[ j ] ];
if ( n.jointName === jointId ) {
jointNode = n;
break;
}
}
if ( jointNode ) {
......@@ -1487,17 +1531,19 @@ THREE.GLTFLoader = ( function () {
return _node;
}.bind( this ) );
} );
}.bind( this ) );
} );
}.bind( this ) );
} );
};
GLTFParser.prototype.loadExtensions = function () {
return _each( this.json.extensions, function ( extension, extensionId ) {
var json = this.json;
return _each( json.extensions, function ( extension, extensionId ) {
switch ( extensionId ) {
......@@ -1559,7 +1605,7 @@ THREE.GLTFLoader = ( function () {
GLTFParser.prototype.loadScenes = function () {
var scope = this;
var json = this.json;
// scene node hierachy builder
......@@ -1568,7 +1614,7 @@ THREE.GLTFLoader = ( function () {
var _node = allNodes[ nodeId ];
parentObject.add( _node );
var node = scope.json.nodes[ nodeId ];
var node = json.nodes[ nodeId ];
if ( node.children ) {
......@@ -1591,7 +1637,7 @@ THREE.GLTFLoader = ( function () {
] ).then( function ( dependencies ) {
return _each( scope.json.scenes, function ( scene ) {
return _each( json.scenes, function ( scene ) {
var _scene = new THREE.Scene();
_scene.name = scene.name;
......
此差异已折叠。
{
"metadata" :
{
"formatVersion" : 3.1,
"sourceFile" : "ninjaHead_Low.obj",
"generatedBy" : "OBJConverter",
"vertices" : 4485,
"faces" : 4810,
"normals" : 4485,
"uvs" : 4543,
"materials" : 0
},
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "default"
}],
"buffers": "NinjaLo_bin.bin"
}
此差异已折叠。
......@@ -168,15 +168,6 @@
"visible" : true
},
"ninja" : {
"geometry" : "NinjaLo",
"material" : "phong_normal",
"position" : [ 75, 10, -30 ],
"rotation" : [ 0, -0.5, 0 ],
"scale" : [ 1.25, 1.25, 1.25 ],
"visible" : true
},
"sittingBox" : {
"geometry" : "sittingBox",
"material" : "phong_morph",
......@@ -443,11 +434,6 @@
"url" : "obj/walt/WaltHead_bin.js"
},
"NinjaLo": {
"type": "binary",
"url" : "obj/ninja/NinjaLo_bin.js"
},
"veyron": {
"type": "binary",
"url" : "obj/veyron/VeyronNoUv_bin.js"
......@@ -580,11 +566,6 @@
"parameters": { "color": 16733491, "specular": 1118481, "shininess": 30, "wireframe": false }
},
"phong_normal": {
"type": "MeshPhongMaterial",
"parameters": { "color": 0, "specular": 16777215, "shininess": 25, "envMap": "cube_reflection", "reflectivity": 0.1, "lightMap": "texture_ao", "normalMap": "texture_normal", "normalScale": [ 1, -1 ] }
},
"phong_morph": {
"type": "MeshPhongMaterial",
"parameters": { "color": 0, "specular": 16777215, "shininess": 50, "envMap": "cube_reflection", "reflectivity": 0.125, "combine": "MixOperation", "shading": "flat", "side": "double", "morphTargets": true }
......@@ -749,21 +730,6 @@
"anisotropy": 4
},
"texture_normal": {
"url": "textures/normal/ninja/normal.jpg",
"anisotropy": 4
},
"texture_ao": {
"url": "textures/normal/ninja/ao.jpg",
"anisotropy": 4
},
"texture_displacement": {
"url": "textures/normal/ninja/displacement.jpg",
"anisotropy": 4
},
"texture_minecraft": {
"url": "textures/minecraft/grass.png",
"magFilter": "NearestFilter",
......
......@@ -93,7 +93,7 @@
};
var loader = new THREE.FBXLoader( manager );
loader.load( 'models/fbx/xsi_man.fbx', function( object ) {
loader.load( 'models/fbx/xsi_man_skinning.fbx', function( object ) {
object.traverse( function( child ) {
......@@ -138,6 +138,10 @@
window.addEventListener( 'resize', onWindowResize, false );
light = new THREE.HemisphereLight(0xffffff, 0x444444, 1.0);
light.position.set(0, 1, 0);
scene.add(light);
light = new THREE.DirectionalLight(0xffffff, 1.0);
light.position.set(0, 1, 0);
scene.add(light);
......
......@@ -43,8 +43,7 @@
<script src="../build/three.js"></script>
<script src="js/controls/OrbitControls.js"></script>
<script src="js/loaders/BinaryLoader.js"></script>
<script src="js/loaders/OBJLoader.js"></script>
<script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script>
......@@ -54,7 +53,7 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var stats, loader;
var stats;
var camera, scene, renderer, controls;
......@@ -145,12 +144,9 @@
// textures
var textureLoader = new THREE.TextureLoader();
var normalMap = textureLoader.load( "textures/normal/ninja/normal.jpg" );
var aoMap = textureLoader.load( "textures/normal/ninja/ao.jpg" );
var displacementMap = textureLoader.load( "textures/normal/ninja/displacement.jpg" );
var normalMap = textureLoader.load( "models/obj/ninja/normal.jpg" );
var aoMap = textureLoader.load( "models/obj/ninja/ao.jpg" );
var displacementMap = textureLoader.load( "models/obj/ninja/displacement.jpg" );
// material
......@@ -196,11 +192,12 @@
//
loader = new THREE.BinaryLoader();
loader.load( "obj/ninja/NinjaLo_bin.js", function( geometry ) {
var loader = new THREE.OBJLoader();
loader.load( "models/obj/ninja/ninjaHead_Low.obj", function ( group ) {
geometry.faceVertexUvs[ 1 ] = geometry.faceVertexUvs[ 0 ]; // 2nd set of UVs required for aoMap
geometry = group.children[ 0 ].geometry;
geometry.attributes.uv2 = geometry.attributes.uv;
geometry.center();
mesh = new THREE.Mesh( geometry, materialNormal );
mesh.scale.multiplyScalar( 25 );
......
......@@ -43,8 +43,7 @@
<script src="../build/three.js"></script>
<script src="js/controls/OrbitControls.js"></script>
<script src="js/loaders/BinaryLoader.js"></script>
<script src="js/loaders/OBJLoader.js"></script>
<script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script>
......@@ -54,7 +53,7 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var stats, loader;
var stats;
var camera, scene, renderer, controls;
var settings = {
......@@ -192,12 +191,9 @@
// textures
var textureLoader = new THREE.TextureLoader();
var normalMap = textureLoader.load( "textures/normal/ninja/normal.jpg" );
var aoMap = textureLoader.load( "textures/normal/ninja/ao.jpg" );
var displacementMap = textureLoader.load( "textures/normal/ninja/displacement.jpg" );
var normalMap = textureLoader.load( "models/obj/ninja/normal.jpg" );
var aoMap = textureLoader.load( "models/obj/ninja/ao.jpg" );
var displacementMap = textureLoader.load( "models/obj/ninja/displacement.jpg" );
// material
......@@ -226,11 +222,12 @@
//
loader = new THREE.BinaryLoader();
loader.load( "obj/ninja/NinjaLo_bin.js", function( geometry ) {
var loader = new THREE.OBJLoader();
loader.load( "models/obj/ninja/ninjaHead_Low.obj", function ( group ) {
geometry.faceVertexUvs[ 1 ] = geometry.faceVertexUvs[ 0 ]; // 2nd set of UVs required for aoMap
geometry = group.children[ 0 ].geometry;
geometry.attributes.uv2 = geometry.attributes.uv;
geometry.center();
mesh = new THREE.Mesh( geometry, material );
mesh.scale.multiplyScalar( 25 );
......
......@@ -72,8 +72,6 @@
var p;
var aloader, bloader;
var composer, effectFocus;
var clock = new THREE.Clock();
......@@ -95,24 +93,15 @@
//
aloader = new THREE.JSONLoader();
bloader = new THREE.BinaryLoader();
aloader.load( "obj/terrain.js", function( geometry ) {
var loader = new THREE.BinaryLoader();
createMesh( geometry, scene, 16.8, -11000, -200, -5000, 0x00ff44, false );
createMesh( geometry, scene, 16.8, 11000, -200, -15000, 0x00ff33, false );
createMesh( geometry, scene, 16.8, 0, -200, -15000, 0x00ff33, false );
createMesh( geometry, scene, 16.8, 0, -200, 15000, 0x00ff33, false );
createMesh( geometry, scene, 16.8, 11000, -200, 15000, 0x00ff22, false );
createMesh( geometry, scene, 16.8, -11000, -200, 5000, 0x00ff11, false );
createMesh( geometry, scene, 16.8, 13000, -200, 5000, 0x00ff55, false );
createMesh( geometry, scene, 16.8, 13000, -200, -5000, 0x00ff66, false );
loader.load( "obj/veyron/VeyronNoUv_bin.js", function( geometry ) {
} );
createMesh( geometry, scene, 6.8, 2200, -200, -100, 0x0055ff, false );
bloader.load( "obj/veyron/VeyronNoUv_bin.js", function( geometry ) { createMesh( geometry, scene, 6.8, 2200, -200, -100, 0x0055ff, false ) } );
} );
bloader.load( "obj/female02/Female02_bin.js", function( geometry ) {
loader.load( "obj/female02/Female02_bin.js", function( geometry ) {
createMesh( geometry, scene, 4.05, -1000, -350, 0, 0xffdd44, true );
createMesh( geometry, scene, 4.05, 0, -350, 0, 0xffffff, true );
......@@ -122,7 +111,7 @@
} );
bloader.load( "obj/male02/Male02_bin.js", function( geometry ) {
loader.load( "obj/male02/Male02_bin.js", function( geometry ) {
createMesh( geometry, scene, 4.05, -500, -350, 600, 0xff7744, true );
createMesh( geometry, scene, 4.05, 500, -350, 0, 0xff5522, true );
......@@ -236,7 +225,7 @@
c = ( i < clones.length -1 ) ? 0x252525 : color;
mesh = new THREE.Points( geometry, new THREE.PointsMaterial( { size: 3, color: c } ) );
mesh = new THREE.Points( geometry, new THREE.PointsMaterial( { size: 30, color: c } ) );
mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
mesh.position.x = x + clones[ i ][ 0 ];
......@@ -251,7 +240,7 @@
} else {
mesh = new THREE.Points( geometry, new THREE.PointsMaterial( { size: 3, color: color } ) );
mesh = new THREE.Points( geometry, new THREE.PointsMaterial( { size: 30, color: color } ) );
mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
mesh.position.x = x;
......
......@@ -544,7 +544,7 @@ PropertyBinding.parseTrackName = function( trackName ) {
// scene:helium_balloon_model:helium_balloon_model.position
// created and tested via https://regex101.com/#javascript
var re = /^((?:\w+[\/:])*)(\w+)?(?:\.(\w+)(?:\[(.+)\])?)?\.(\w+)(?:\[(.+)\])?$/;
var re = /^((?:[\w-]+[\/:])*)([\w-]+)?(?:\.([\w-]+)(?:\[(.+)\])?)?\.([\w-]+)(?:\[(.+)\])?$/;
var matches = re.exec( trackName );
if ( ! matches ) {
......
......@@ -579,11 +579,11 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
}
var positions = this.attributes.position.array;
var position = this.attributes.position;
if ( positions !== undefined ) {
if ( position !== undefined ) {
this.boundingBox.setFromArray( positions );
this.boundingBox.setFromBufferAttribute( position );
} else {
......@@ -612,14 +612,13 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
}
var positions = this.attributes.position;
var position = this.attributes.position;
if ( positions ) {
if ( position ) {
var array = positions.array;
var center = this.boundingSphere.center;
box.setFromArray( array );
box.setFromBufferAttribute( position );
box.getCenter( center );
// hoping to find a boundingSphere with a radius smaller than the
......@@ -627,9 +626,11 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
var maxRadiusSq = 0;
for ( var i = 0, il = array.length; i < il; i += 3 ) {
for ( var i = 0, il = position.count; i < il; i ++ ) {
vector.fromArray( array, i );
vector.x = position.getX( i );
vector.y = position.getY( i );
vector.z = position.getZ( i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
}
......
......@@ -10,7 +10,7 @@ function MultiMaterial( materials ) {
this.type = 'MultiMaterial';
this.materials = materials instanceof Array ? materials : [];
this.materials = Array.isArray( materials ) ? materials : [];
this.visible = true;
......
......@@ -59,6 +59,37 @@ Box3.prototype = {
},
setFromBufferAttribute: function ( attribute ) {
var minX = + Infinity;
var minY = + Infinity;
var minZ = + Infinity;
var maxX = - Infinity;
var maxY = - Infinity;
var maxZ = - Infinity;
for ( var i = 0, l = attribute.count; i < l; i ++ ) {
var x = attribute.getX( i );
var y = attribute.getY( i );
var z = attribute.getZ( i );
if ( x < minX ) minX = x;
if ( y < minY ) minY = y;
if ( z < minZ ) minZ = z;
if ( x > maxX ) maxX = x;
if ( y > maxY ) maxY = y;
if ( z > maxZ ) maxZ = z;
}
this.min.set( minX, minY, minZ );
this.max.set( maxX, maxY, maxZ );
},
setFromPoints: function ( points ) {
this.makeEmpty();
......
#if defined( USE_ENVMAP ) || defined( PHYSICAL )
uniform float reflectivity;
uniform float envMapIntenstiy;
uniform float envMapIntensity;
#endif
#ifdef USE_ENVMAP
......
......@@ -11,8 +11,6 @@ uniform float opacity;
uniform float clearCoatRoughness;
#endif
uniform float envMapIntensity; // temporary
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
......
......@@ -21,11 +21,15 @@ function WebGLIndexedBufferRenderer( gl, extensions, infoRender ) {
type = gl.UNSIGNED_INT;
size = 4;
} else {
} else if ( index.array instanceof Uint16Array ) {
type = gl.UNSIGNED_SHORT;
size = 2;
} else {
type = gl.UNSIGNED_BYTE;
size = 1;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册