提交 6d25c62f 编写于 作者: D Don McCurdy

GLTFLoader: Remove old and unstable extensions.

上级 0d1909eb
......@@ -28,16 +28,10 @@
<ul>
<li>
<a target="_blank" href="https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_pbrSpecularGlossiness">
<a target="_blank" href="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness">
KHR_materials_pbrSpecularGlossiness
</a>
</li>
<li>
<a target="_blank" href="https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common">
KHR_materials_common
</a>
(experimental)
</li>
<li>
KHR_lights (experimental)
</li>
......
......@@ -121,12 +121,6 @@ THREE.GLTFLoader = ( function () {
}
if ( json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_COMMON ) >= 0 ) {
extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] = new GLTFMaterialsCommonExtension( json );
}
if ( json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ) >= 0 ) {
extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
......@@ -208,7 +202,6 @@ THREE.GLTFLoader = ( function () {
var EXTENSIONS = {
KHR_BINARY_GLTF: 'KHR_binary_glTF',
KHR_LIGHTS: 'KHR_lights',
KHR_MATERIALS_COMMON: 'KHR_materials_common',
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness'
};
......@@ -296,107 +289,6 @@ THREE.GLTFLoader = ( function () {
}
/**
* Common Materials Extension
*
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common
*/
function GLTFMaterialsCommonExtension( json ) {
this.name = EXTENSIONS.KHR_MATERIALS_COMMON;
}
GLTFMaterialsCommonExtension.prototype.getMaterialType = function ( material ) {
var khrMaterial = material.extensions[ this.name ];
switch ( khrMaterial.type ) {
case 'commonBlinn' :
case 'commonPhong' :
return THREE.MeshPhongMaterial;
case 'commonLambert' :
return THREE.MeshLambertMaterial;
case 'commonConstant' :
default :
return THREE.MeshBasicMaterial;
}
};
GLTFMaterialsCommonExtension.prototype.extendParams = function ( materialParams, material, parser ) {
var khrMaterial = material.extensions[ this.name ];
var pending = [];
var keys = [];
// TODO: Currently ignored: 'ambientFactor', 'ambientTexture'
switch ( khrMaterial.type ) {
case 'commonBlinn' :
case 'commonPhong' :
keys.push( 'diffuseFactor', 'diffuseTexture', 'specularFactor', 'specularTexture', 'shininessFactor' );
break;
case 'commonLambert' :
keys.push( 'diffuseFactor', 'diffuseTexture' );
break;
case 'commonConstant' :
default :
break;
}
var materialValues = {};
keys.forEach( function ( v ) {
if ( khrMaterial[ v ] !== undefined ) materialValues[ v ] = khrMaterial[ v ];
} );
if ( materialValues.diffuseFactor !== undefined ) {
materialParams.color = new THREE.Color().fromArray( materialValues.diffuseFactor );
materialParams.opacity = materialValues.diffuseFactor[ 3 ];
}
if ( materialValues.diffuseTexture !== undefined ) {
pending.push( parser.assignTexture( materialParams, 'map', materialValues.diffuseTexture.index ) );
}
if ( materialValues.specularFactor !== undefined ) {
materialParams.specular = new THREE.Color().fromArray( materialValues.specularFactor );
}
if ( materialValues.specularTexture !== undefined ) {
pending.push( parser.assignTexture( materialParams, 'specularMap', materialValues.specularTexture.index ) );
}
if ( materialValues.shininessFactor !== undefined ) {
materialParams.shininess = materialValues.shininessFactor;
}
return Promise.all( pending );
};
/* BINARY EXTENSION */
var BINARY_EXTENSION_BUFFER_NAME = 'binary_glTF';
......@@ -468,7 +360,7 @@ THREE.GLTFLoader = ( function () {
/**
* Specular-Glossiness Extension
*
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
*/
function GLTFMaterialsPbrSpecularGlossinessExtension() {
......@@ -1811,13 +1703,7 @@ THREE.GLTFLoader = ( function () {
var pending = [];
if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] ) {
var khcExtension = extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ];
materialType = khcExtension.getMaterialType( materialDef );
pending.push( khcExtension.extendParams( materialParams, materialDef, parser ) );
} else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
var sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
materialType = sgExtension.getMaterialType( materialDef );
......
precision highp float;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat3 u_normalMatrix;
uniform mat4 u_jointMatrix[19];
attribute vec3 a_position;
varying vec3 v_position;
attribute vec3 a_normal;
varying vec3 v_normal;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
attribute vec4 a_joint;
attribute vec4 a_weight;
void main(void) {
mat4 skinMat = a_weight.x * u_jointMatrix[int(a_joint.x)];
skinMat += a_weight.y * u_jointMatrix[int(a_joint.y)];
skinMat += a_weight.z * u_jointMatrix[int(a_joint.z)];
skinMat += a_weight.w * u_jointMatrix[int(a_joint.w)];
vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0);
v_position = pos.xyz;
gl_Position = u_projectionMatrix * pos;
v_normal = u_normalMatrix * mat3(skinMat) * a_normal;
v_texcoord0 = a_texcoord0;
}
precision highp float;
uniform vec4 u_ambient;
uniform sampler2D u_diffuse;
uniform vec4 u_emission;
uniform vec4 u_specular;
uniform float u_shininess;
uniform float u_transparency;
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord0;
void main(void) {
vec3 normal = normalize(v_normal);
vec4 diffuse = texture2D(u_diffuse, v_texcoord0);
vec3 diffuseLight = vec3(0.0, 0.0, 0.0);
vec3 specular = u_specular.rgb;
vec3 specularLight = vec3(0.0, 0.0, 0.0);
vec3 emission = u_emission.rgb;
vec3 ambient = u_ambient.rgb;
vec3 viewDir = -normalize(v_position);
vec3 ambientLight = vec3(0.0, 0.0, 0.0);
ambientLight += vec3(0.2, 0.2, 0.2);
vec3 l = vec3(0.0, 0.0, 1.0);
diffuseLight += vec3(1.0, 1.0, 1.0) * max(dot(normal, l), 0.);
vec3 reflectDir = reflect(-l, normal);
float specularIntensity = max(0., pow(max(dot(reflectDir, viewDir), 0.), u_shininess));
specularLight += vec3(1.0, 1.0, 1.0) * specularIntensity;
vec3 color = vec3(0.0, 0.0, 0.0);
color += diffuse.rgb * diffuseLight;
color += specular * specularLight;
color += emission;
color += ambient * ambientLight;
gl_FragColor = vec4(color * diffuse.a * u_transparency, diffuse.a * u_transparency);
}
{
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5123,
"count" : 12636,
"max" : [
2297
],
"min" : [
0
],
"type" : "SCALAR"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 2298,
"max" : [
96.17990112304688,
53.925201416015625,
-9.929369926452637
],
"min" : [
-69.29850006103516,
-61.32820129394531,
-163.97000122070312
],
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 2298,
"max" : [
0.9971618056297302,
0.9985961318016052,
1.0
],
"min" : [
-0.99993896484375,
-0.999847412109375,
-0.99957275390625
],
"type" : "VEC3"
},
{
"bufferView" : 3,
"componentType" : 5126,
"count" : 2298,
"max" : [
0.9999999403953552,
0.9984003901481628,
0.8631033897399902,
1.0
],
"min" : [
-0.6876732707023621,
-0.99998939037323,
-0.9818168878555298,
1.0
],
"type" : "VEC4"
},
{
"bufferView" : 4,
"componentType" : 5126,
"count" : 2298,
"max" : [
0.9833459854125977,
0.9800370000302792
],
"min" : [
0.026409000158309937,
0.01996302604675293
],
"type" : "VEC2"
}
],
"asset" : {
"generator" : "Khronos Blender glTF 2.0 exporter",
"version" : "2.0"
},
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 25272,
"byteOffset" : 0,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 27576,
"byteOffset" : 25272,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 27576,
"byteOffset" : 52848,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 36768,
"byteOffset" : 80424,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 18384,
"byteOffset" : 117192,
"target" : 34962
}
],
"buffers" : [
{
"byteLength" : 135576,
"uri" : "Duck.bin"
}
],
"cameras" : [
{
"name" : "Camera",
"perspective" : {
"aspectRatio" : 1.703595982340029,
"yfov" : 0.5033799409866333,
"zfar" : 100.0,
"znear" : 0.10000000149011612
},
"type" : "perspective"
},
{
"name" : "cameraShape1",
"perspective" : {
"aspectRatio" : 1.6868377569213957,
"yfov" : 0.563195526599884,
"zfar" : 10000.0,
"znear" : 1.0
},
"type" : "perspective"
}
],
"extensions" : {
"KHR_lights" : {
"lights" : [
{
"color" : [
1.0,
1.0,
1.0
],
"name" : "directionalLightShape1",
"type" : "directional"
},
{
"color" : [
1.0,
1.0,
1.0
],
"name" : "Lamp",
"quadraticAttenuation" : 0.03333335240683057,
"type" : "point"
},
{
"color" : [
0.0,
0.0,
0.0
],
"name" : "Ambient_Scene",
"type" : "ambient"
}
]
}
},
"extensionsRequired" : [
"KHR_materials_common",
"KHR_lights"
],
"extensionsUsed" : [
"KHR_materials_common",
"KHR_lights"
],
"images" : [
{
"uri" : "DuckCM.png"
}
],
"materials" : [
{
"alphaMode" : "BLEND",
"emissiveFactor" : [
0.0,
0.0,
0.0
],
"extensions" : {
"KHR_materials_common" : {
"ambientFactor" : [
1.0,
1.0,
1.0
],
"diffuseFactor" : [
0.6400000190734865,
0.6400000190734865,
0.6400000190734865,
1.0
],
"diffuseTexture" : {
"index" : 0
},
"shininessFactor" : 12.298039215686275,
"specularFactor" : [
0.0,
0.0,
0.0
],
"type" : "commonPhong"
}
},
"name" : "blinn3"
}
],
"meshes" : [
{
"name" : "LOD3spShape",
"primitives" : [
{
"attributes" : {
"NORMAL" : 2,
"POSITION" : 1,
"TANGENT" : 3,
"TEXCOORD_0" : 4
},
"indices" : 0,
"material" : 0
}
]
}
],
"nodes" : [
{
"camera" : 0,
"name" : "Correction_Camera",
"rotation" : [
-0.7071067690849304,
-0.0,
0.0,
0.7071067690849304
]
},
{
"children" : [
0
],
"name" : "Camera",
"rotation" : [
0.483536034822464,
0.33687159419059753,
-0.20870360732078552,
0.7804827094078064
],
"translation" : [
7.481131553649902,
5.34366512298584,
6.5076398849487305
]
},
{
"camera" : 1,
"name" : "Correction_camera1",
"rotation" : [
-0.7071067690849304,
-0.0,
0.0,
0.7071067690849304
]
},
{
"children" : [
2
],
"name" : "camera1",
"rotation" : [
0.1602192521095276,
0.8370952010154724,
-0.4046676754951477,
0.33142927289009094
],
"scale" : [
0.009999999776482582,
0.009999999776482582,
0.009999999776482582
],
"translation" : [
4.001130104064941,
4.6326398849487305,
-4.310780048370361
]
},
{
"extensions" : {
"KHR_lights" : {
"light" : 0
}
},
"name" : "Correction_directionalLight1",
"rotation" : [
-0.7071067690849304,
-0.0,
0.0,
0.7071067690849304
]
},
{
"children" : [
4
],
"name" : "directionalLight1",
"rotation" : [
0.14142043888568878,
0.9110735058784485,
-0.3837852478027344,
0.051520030945539474
],
"scale" : [
0.009999998845160007,
0.009999999776482582,
0.009999999776482582
],
"translation" : [
1.4865400791168213,
1.8367199897766113,
-2.9217898845672607
]
},
{
"extensions" : {
"KHR_lights" : {
"light" : 1
}
},
"name" : "Correction_Lamp",
"rotation" : [
-0.7071067690849304,
-0.0,
0.0,
0.7071067690849304
]
},
{
"children" : [
6
],
"name" : "Lamp",
"rotation" : [
0.16907575726509094,
0.7558802962303162,
-0.27217137813568115,
0.570947527885437
],
"scale" : [
1.0,
1.0,
0.9999999403953552
],
"translation" : [
4.076245307922363,
5.903861999511719,
-1.0054539442062378
]
},
{
"mesh" : 0,
"name" : "LOD3sp",
"rotation" : [
0.7071068286895752,
0.0,
-0.0,
0.7071067094802856
],
"scale" : [
0.009999999776482582,
0.009999999776482582,
0.009999999776482582
]
}
],
"samplers" : [
{}
],
"scene" : 0,
"scenes" : [
{
"extensions" : {
"KHR_lights" : {
"light" : 2
}
},
"name" : "Scene",
"nodes" : [
5,
3,
8,
7,
1
]
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
}
]
}
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"children": [
3,
2,
1
],
"matrix": [
0.009999999776482582,
0.0,
0.0,
0.0,
0.0,
0.009999999776482582,
0.0,
0.0,
0.0,
0.0,
0.009999999776482582,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
"matrix": [
-0.9546916484832764,
0.2181433141231537,
-0.2024286538362503,
0.0,
0.014671952463686468,
0.7138853073120117,
0.7001089453697205,
0.0,
0.2972349226474762,
0.6654181480407715,
-0.6847409009933472,
0.0,
148.6540069580078,
183.6720123291016,
-292.1790161132813,
1.0
]
},
{
"matrix": [
-0.7289686799049377,
0.0,
-0.6845470666885376,
0.0,
-0.4252049028873444,
0.7836934328079224,
0.4527972936630249,
0.0,
0.5364750623703003,
0.6211478114128113,
-0.571287989616394,
0.0,
400.1130065917969,
463.2640075683594,
-431.0780334472656,
1.0
],
"camera": 0
},
{
"mesh": 0
}
],
"cameras": [
{
"perspective": {
"aspectRatio": 1.5,
"yfov": 0.6605925559997559,
"zfar": 10000.0,
"znear": 1.0
},
"type": "perspective"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 2,
"TEXCOORD_0": 3
},
"indices": 0,
"mode": 4,
"material": 0
}
],
"name": "LOD3spShape"
}
],
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 12636,
"max": [
2398
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 2399,
"max": [
0.9995989799499512,
0.999580979347229,
0.9984359741210938
],
"min": [
-0.9990839958190918,
-1.0,
-0.9998319745063782
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 28788,
"componentType": 5126,
"count": 2399,
"max": [
96.17990112304688,
163.97000122070313,
53.92519760131836
],
"min": [
-69.29850006103516,
9.929369926452637,
-61.32819747924805
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 2399,
"max": [
0.9833459854125976,
0.9800369739532472
],
"min": [
0.026409000158309938,
0.01996302604675293
],
"type": "VEC2"
}
],
"materials": [
{
"values": {
"ambient": [
0.0,
0.0,
0.0,
1.0
],
"diffuse": [
0
],
"emission": [
0.0,
0.0,
0.0,
1.0
],
"specular": [
0.0,
0.0,
0.0,
1.0
],
"shininess": [
0.30000001192092898
],
"transparency": [
1.0
]
},
"technique": 0
}
],
"textures": [
{
"sampler": 0,
"source": 0
}
],
"images": [
{
"uri": "DuckCM.png"
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9986,
"wrapS": 10497,
"wrapT": 10497
}
],
"techniques": [
{
"attributes": {
"a_normal": "normal",
"a_position": "position",
"a_texcoord0": "texcoord0"
},
"parameters": {
"ambient": {
"type": 35666
},
"diffuse": {
"type": 35678
},
"emission": {
"type": 35666
},
"light0Color": {
"value": [
1.0,
1.0,
1.0
],
"type": 35665
},
"light0Transform": {
"semantic": "MODELVIEW",
"node": 1,
"type": 35676
},
"modelViewMatrix": {
"semantic": "MODELVIEW",
"type": 35676
},
"normal": {
"semantic": "NORMAL",
"type": 35665
},
"normalMatrix": {
"semantic": "MODELVIEWINVERSETRANSPOSE",
"type": 35675
},
"position": {
"semantic": "POSITION",
"type": 35665
},
"projectionMatrix": {
"semantic": "PROJECTION",
"type": 35676
},
"shininess": {
"type": 5126
},
"specular": {
"type": 35666
},
"texcoord0": {
"semantic": "TEXCOORD_0",
"type": 35665
},
"transparency": {
"type": 5126
}
},
"program": 0,
"states": {
"enable": [
2884,
2929
]
},
"uniforms": {
"u_ambient": "ambient",
"u_diffuse": "diffuse",
"u_emission": "emission",
"u_light0Color": "light0Color",
"u_light0Transform": "light0Transform",
"u_modelViewMatrix": "modelViewMatrix",
"u_normalMatrix": "normalMatrix",
"u_projectionMatrix": "projectionMatrix",
"u_shininess": "shininess",
"u_specular": "specular",
"u_transparency": "transparency"
}
}
],
"programs": [
{
"attributes": [
"a_normal",
"a_position",
"a_texcoord0"
],
"fragmentShader": 1,
"vertexShader": 0
}
],
"shaders": [
{
"type": 35633,
"uri": "Duck0.vert"
},
{
"type": 35632,
"uri": "Duck1.frag"
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 76768,
"byteLength": 25272,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 57576,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 57576,
"byteLength": 19192,
"byteStride": 8,
"target": 34962
}
],
"buffers": [
{
"byteLength": 102040,
"uri": "Duck0.bin"
}
],
"extensionsRequired": [
"KHR_technique_webgl"
],
"extensionsUsed": [
"KHR_technique_webgl"
]
}
precision highp float;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat3 u_normalMatrix;
uniform mat4 u_light0Transform;
attribute vec3 a_position;
varying vec3 v_position;
attribute vec3 a_normal;
varying vec3 v_normal;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
varying vec3 v_light0Direction;
void main(void) {
vec4 pos = u_modelViewMatrix * vec4(a_position,1.0);
v_position = pos.xyz;
gl_Position = u_projectionMatrix * pos;
v_normal = u_normalMatrix * a_normal;
v_texcoord0 = a_texcoord0;
v_light0Direction = mat3(u_light0Transform) * vec3(0., 0., 1.);
}
precision highp float;
uniform vec4 u_ambient;
uniform sampler2D u_diffuse;
uniform vec4 u_emission;
uniform vec4 u_specular;
uniform float u_shininess;
uniform float u_transparency;
uniform vec3 u_light0Color;
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord0;
varying vec3 v_light0Direction;
void main(void) {
vec3 normal = normalize(v_normal);
vec4 diffuse = texture2D(u_diffuse, v_texcoord0);
vec3 diffuseLight = vec3(0.0, 0.0, 0.0);
vec3 specular = u_specular.rgb;
vec3 specularLight = vec3(0.0, 0.0, 0.0);
vec3 emission = u_emission.rgb;
vec3 ambient = u_ambient.rgb;
vec3 viewDir = -normalize(v_position);
vec3 ambientLight = vec3(0.0, 0.0, 0.0);
{
vec3 l = normalize(v_light0Direction);
float attenuation = 1.0;
diffuseLight += u_light0Color * max(dot(normal, l), 0.) * attenuation;
vec3 h = normalize(l + viewDir);
float specularIntensity = max(0., pow(max(dot(normal, h), 0.), u_shininess)) * attenuation;
specularLight += u_light0Color * specularIntensity;
}
ambientLight += vec3(0.2, 0.2, 0.2);
vec3 color = vec3(0.0, 0.0, 0.0);
color += diffuse.rgb * diffuseLight;
color += specular * specularLight;
color += emission;
color += ambient * ambientLight;
gl_FragColor = vec4(color * diffuse.a * u_transparency, diffuse.a * u_transparency);
}
precision highp float;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat3 u_normalMatrix;
uniform mat4 u_jointMatrix[32];
attribute vec3 a_position;
varying vec3 v_position;
attribute vec3 a_normal;
varying vec3 v_normal;
attribute vec2 a_texcoord0;
varying vec2 v_texcoord0;
attribute vec4 a_joint;
attribute vec4 a_weight;
void main(void) {
mat4 skinMat = a_weight.x * u_jointMatrix[int(a_joint.x)];
skinMat += a_weight.y * u_jointMatrix[int(a_joint.y)];
skinMat += a_weight.z * u_jointMatrix[int(a_joint.z)];
skinMat += a_weight.w * u_jointMatrix[int(a_joint.w)];
vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0);
v_position = pos.xyz;
gl_Position = u_projectionMatrix * pos;
v_normal = u_normalMatrix * mat3(skinMat) * a_normal;
v_texcoord0 = a_texcoord0;
}
precision highp float;
uniform vec4 u_ambient;
uniform sampler2D u_diffuse;
uniform vec4 u_emission;
uniform vec4 u_specular;
uniform float u_shininess;
uniform float u_transparency;
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord0;
void main(void) {
vec3 normal = normalize(v_normal);
vec4 diffuse = texture2D(u_diffuse, v_texcoord0);
vec3 diffuseLight = vec3(0.0, 0.0, 0.0);
vec3 specular = u_specular.rgb;
vec3 specularLight = vec3(0.0, 0.0, 0.0);
vec3 emission = u_emission.rgb;
vec3 ambient = u_ambient.rgb;
vec3 viewDir = -normalize(v_position);
vec3 ambientLight = vec3(0.0, 0.0, 0.0);
ambientLight += vec3(0.2, 0.2, 0.2);
vec3 l = vec3(0.0, 0.0, 1.0);
diffuseLight += vec3(1.0, 1.0, 1.0) * max(dot(normal, l), 0.);
vec3 h = normalize(l + viewDir);
float specularIntensity = max(0., pow(max(dot(normal, h), 0.), u_shininess));
specularLight += vec3(1.0, 1.0, 1.0) * specularIntensity;
vec3 color = vec3(0.0, 0.0, 0.0);
color += diffuse.rgb * diffuseLight;
color += specular * specularLight;
color += emission;
color += ambient * ambientLight;
gl_FragColor = vec4(color * diffuse.a * u_transparency, diffuse.a * u_transparency);
}
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"children": [
4,
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
"mesh": 0,
"skin": 0
},
{
"children": [
3
],
"translation": [
0.0,
-3.156060017772689e-7,
-4.1803297996521
],
"rotation": [
-0.7047404050827026,
-0.0,
-0.0,
-0.7094652056694031
],
"scale": [
1.0,
0.9999998807907105,
0.9999998807907105
]
},
{
"translation": [
0.0,
4.18717098236084,
0.0
],
"rotation": [
-0.0020521103870123626,
-9.94789530750495e-8,
-0.00029137087403796613,
-0.999997854232788
],
"scale": [
1.0,
1.0,
1.0000001192092896
]
},
{
"children": [
2
]
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"JOINTS_0": 1,
"NORMAL": 2,
"POSITION": 3,
"WEIGHTS_0": 4
},
"indices": 0,
"mode": 4,
"material": 0
}
],
"name": "Cylinder"
}
],
"animations": [
{
"channels": [
{
"sampler": 0,
"target": {
"node": 2,
"path": "translation"
}
},
{
"sampler": 1,
"target": {
"node": 2,
"path": "rotation"
}
},
{
"sampler": 2,
"target": {
"node": 2,
"path": "scale"
}
}
],
"samplers": [
{
"input": 5,
"interpolation": "LINEAR",
"output": 6
},
{
"input": 5,
"interpolation": "LINEAR",
"output": 7
},
{
"input": 5,
"interpolation": "LINEAR",
"output": 8
}
]
},
{
"channels": [
{
"sampler": 0,
"target": {
"node": 3,
"path": "translation"
}
},
{
"sampler": 1,
"target": {
"node": 3,
"path": "rotation"
}
},
{
"sampler": 2,
"target": {
"node": 3,
"path": "scale"
}
}
],
"samplers": [
{
"input": 9,
"interpolation": "LINEAR",
"output": 10
},
{
"input": 9,
"interpolation": "LINEAR",
"output": 11
},
{
"input": 9,
"interpolation": "LINEAR",
"output": 12
}
]
}
],
"skins": [
{
"inverseBindMatrices": 13,
"skeleton": 2,
"joints": [
2,
3
],
"name": "Armature"
}
],
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 564,
"max": [
95
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5123,
"count": 96,
"max": [
1,
1,
0,
0
],
"min": [
0,
0,
0,
0
],
"type": "VEC4"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 96,
"max": [
0.998198390007019,
0.998198390007019,
0.6888381242752075
],
"min": [
-0.998198390007019,
-0.998198390007019,
-0.644473135471344
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 1152,
"componentType": 5126,
"count": 96,
"max": [
1.0,
1.0,
4.575077056884766
],
"min": [
-1.0,
-0.9999995827674866,
-4.575077056884766
],
"type": "VEC3"
},
{
"bufferView": 3,
"byteOffset": 0,
"componentType": 5126,
"count": 96,
"max": [
1.0,
0.261398196220398,
0.0,
0.0
],
"min": [
0.738601803779602,
0.0,
0.0,
0.0
],
"type": "VEC4"
},
{
"bufferView": 4,
"byteOffset": 0,
"componentType": 5126,
"count": 3,
"max": [
2.083333015441895
],
"min": [
0.04166661947965622
],
"type": "SCALAR"
},
{
"bufferView": 5,
"byteOffset": 0,
"componentType": 5126,
"count": 3,
"max": [
0.0,
-3.156060017772689e-7,
-4.1803297996521
],
"min": [
0.0,
-3.156060017772689e-7,
-4.1803297996521
],
"type": "VEC3"
},
{
"bufferView": 6,
"byteOffset": 0,
"componentType": 5126,
"count": 3,
"max": [
-0.7047404050827026,
-0.0,
-0.0,
-0.7094652056694031
],
"min": [
-0.7047404050827026,
-0.0,
-0.0,
-0.7094652056694031
],
"type": "VEC4"
},
{
"bufferView": 5,
"byteOffset": 36,
"componentType": 5126,
"count": 3,
"max": [
1.0,
0.9999998807907105,
0.9999998807907105
],
"min": [
1.0,
0.9999998807907105,
0.9999998807907105
],
"type": "VEC3"
},
{
"bufferView": 4,
"byteOffset": 12,
"componentType": 5126,
"count": 3,
"max": [
2.083333015441895
],
"min": [
0.04166661947965622
],
"type": "SCALAR"
},
{
"bufferView": 5,
"byteOffset": 72,
"componentType": 5126,
"count": 3,
"max": [
0.0,
4.18717098236084,
0.0
],
"min": [
0.0,
4.18717098236084,
0.0
],
"type": "VEC3"
},
{
"bufferView": 6,
"byteOffset": 48,
"componentType": 5126,
"count": 3,
"max": [
0.2933785021305084,
-9.94789530750495e-8,
-0.0002783441450446844,
-0.9559963345527648
],
"min": [
-0.0020521103870123626,
-0.00008614854596089572,
-0.00029137087403796613,
-0.999997854232788
],
"type": "VEC4"
},
{
"bufferView": 5,
"byteOffset": 108,
"componentType": 5126,
"count": 3,
"max": [
1.0,
1.0,
1.0000001192092896
],
"min": [
1.0,
1.0,
1.0000001192092896
],
"type": "VEC3"
},
{
"bufferView": 7,
"byteOffset": 0,
"componentType": 5126,
"count": 2,
"max": [
1.0,
0.0,
0.000001394809942212305,
0.0,
0.000002896920022976701,
0.006681859027594328,
-0.9999778270721436,
0.0,
0.0005827349959872663,
0.9999966025352478,
0.006681739818304777,
0.0,
0.0,
4.18023681640625,
0.02795993909239769,
1.0
],
"min": [
0.9999999403953552,
-0.0005827400018461049,
0.0,
0.0,
0.0,
0.002577662002295256,
-0.9999967217445374,
0.0,
0.0,
0.999977707862854,
0.002577601931989193,
0.0,
-0.000004012620138382772,
-0.006818830035626888,
0.027931740507483484,
1.0
],
"type": "MAT4"
}
],
"materials": [
{
"extensions": {
"KHR_materials_common": {
"doubleSided": false,
"jointCount": 2,
"technique": "PHONG",
"transparent": false,
"values": {
"ambient": [
0.0,
0.0,
0.0,
1.0
],
"diffuse": [
0.27963539958000185,
0.6399999856948853,
0.21094390749931336,
1.0
],
"emission": [
0.0,
0.0,
0.0,
1.0
],
"specular": [
0.5,
0.5,
0.5,
1.0
],
"shininess": [
50.0
],
"transparency": [
1.0
]
},
"name": "Material_001-effect"
}
},
"name": "Material_001-effect"
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 5000,
"byteLength": 1128,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 4208,
"byteLength": 768,
"byteStride": 8,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 1904,
"byteLength": 2304,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 224,
"byteLength": 1536,
"byteStride": 16,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 4976,
"byteLength": 24
},
{
"buffer": 0,
"byteOffset": 1760,
"byteLength": 144
},
{
"buffer": 0,
"byteOffset": 128,
"byteLength": 96
},
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 128
}
],
"buffers": [
{
"byteLength": 6128,
"uri": "RiggedSimple0.bin"
}
],
"extensionsRequired": [
"KHR_materials_common"
],
"extensionsUsed": [
"KHR_materials_common"
]
}
precision highp float;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat3 u_normalMatrix;
uniform mat4 u_jointMatrix[2];
attribute vec3 a_position;
varying vec3 v_position;
attribute vec3 a_normal;
varying vec3 v_normal;
attribute vec4 a_joint;
attribute vec4 a_weight;
void main(void) {
mat4 skinMat = a_weight.x * u_jointMatrix[int(a_joint.x)];
skinMat += a_weight.y * u_jointMatrix[int(a_joint.y)];
skinMat += a_weight.z * u_jointMatrix[int(a_joint.z)];
skinMat += a_weight.w * u_jointMatrix[int(a_joint.w)];
vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0);
v_position = pos.xyz;
gl_Position = u_projectionMatrix * pos;
v_normal = u_normalMatrix * mat3(skinMat) * a_normal;
}
precision highp float;
uniform vec4 u_ambient;
uniform vec4 u_diffuse;
uniform vec4 u_emission;
uniform vec4 u_specular;
uniform float u_shininess;
uniform float u_transparency;
varying vec3 v_position;
varying vec3 v_normal;
void main(void) {
vec3 normal = normalize(v_normal);
vec4 diffuse = u_diffuse;
vec3 diffuseLight = vec3(0.0, 0.0, 0.0);
vec3 specular = u_specular.rgb;
vec3 specularLight = vec3(0.0, 0.0, 0.0);
vec3 emission = u_emission.rgb;
vec3 ambient = u_ambient.rgb;
vec3 viewDir = -normalize(v_position);
vec3 ambientLight = vec3(0.0, 0.0, 0.0);
ambientLight += vec3(0.2, 0.2, 0.2);
vec3 l = vec3(0.0, 0.0, 1.0);
diffuseLight += vec3(1.0, 1.0, 1.0) * max(dot(normal, l), 0.);
vec3 reflectDir = reflect(-l, normal);
float specularIntensity = max(0., pow(max(dot(reflectDir, viewDir), 0.), u_shininess));
specularLight += vec3(1.0, 1.0, 1.0) * specularIntensity;
vec3 color = vec3(0.0, 0.0, 0.0);
color += diffuse.rgb * diffuseLight;
color += specular * specularLight;
color += emission;
color += ambient * ambientLight;
gl_FragColor = vec4(color * diffuse.a * u_transparency, diffuse.a * u_transparency);
}
......@@ -89,7 +89,6 @@
<option value="glTF">None (Default)</option>
<option value="glTF-Embedded">None (Embedded)</option>
<option value="glTF-Binary">None (Binary)</option>
<option value="glTF-MaterialsCommon">Common Materials</option>
<option value="glTF-pbrSpecularGlossiness">Specular-Glossiness (PBR)</option>
</select>
</div>
......@@ -446,7 +445,7 @@
addLights:true,
addGround:true,
shadows:true,
extensions: ['glTF', 'glTF-Embedded', 'glTF-MaterialsCommon', 'glTF-pbrSpecularGlossiness', 'glTF-Binary']
extensions: ['glTF', 'glTF-Embedded', 'glTF-pbrSpecularGlossiness', 'glTF-Binary']
},
{
name : "Monster", url : "./models/gltf/Monster/%s/Monster.gltf",
......@@ -458,7 +457,6 @@
addLights:true,
shadows:true,
addGround:true,
// TODO: 'glTF-MaterialsCommon'
extensions: ['glTF', 'glTF-Embedded', 'glTF-pbrSpecularGlossiness', 'glTF-Binary']
},
{
......@@ -468,7 +466,6 @@
addLights:true,
addGround:true,
shadows:true,
// TODO: 'glTF-MaterialsCommon'
extensions: ['glTF', 'glTF-Embedded', 'glTF-pbrSpecularGlossiness', 'glTF-Binary']
},
{
......@@ -478,7 +475,6 @@
addLights:true,
addGround:true,
shadows:true,
// TODO: 'glTF-MaterialsCommon'
extensions: ['glTF', 'glTF-Embedded', 'glTF-pbrSpecularGlossiness', 'glTF-Binary']
},
{
......@@ -488,7 +484,6 @@
objectRotation: new THREE.Euler(0, 90, 0),
addLights:true,
shadows:true,
// TODO: 'glTF-MaterialsCommon'
extensions: ['glTF', 'glTF-Embedded', 'glTF-pbrSpecularGlossiness', 'glTF-Binary']
},
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册