提交 5c43e946 编写于 作者: A alteredq

Added handling of CTM meshes to SceneLoader.

Not really sure what would be the best way to deal with such external loader types dependencies.
上级 829b236a
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -36,7 +36,9 @@
"position" : [ -30, -5, 25 ],
"rotation" : [ 0, 0.8, 0 ],
"scale" : [ 1, 1, 1 ],
"visible" : true
"visible" : true,
"children" : {
}
},
"sphere_lambert" : {
......@@ -145,12 +147,21 @@
"walt" : {
"geometry" : "WaltHead",
"materials": [ "lambert_cube" ],
"position" : [ -45, 10, 0 ],
"rotation" : [ 0, 0, 0 ],
"position" : [ -75, 10, -30 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 0.5, 0.5, 0.5 ],
"visible" : true
},
"ben" : {
"geometry" : "ben",
"materials": [ "phong_ben" ],
"position" : [ -45, -10, 0 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 55, 55, 55 ],
"visible" : true
},
"ninja" : {
"geometry" : "NinjaLo",
"materials": [ "phong_normal" ],
......@@ -288,6 +299,13 @@
"url" : "obj/veyron/VeyronNoUv_bin.js"
},
"ben": {
"type": "ctm_mesh",
"url" : "models/ctm/ben.ctm",
"useWorkers" : true,
"useBuffers" : true
},
"colorcube": {
"type": "embedded_mesh",
"id" : "cube_fvc"
......@@ -355,9 +373,14 @@
"parameters": { "color": 16711680, "specular": 16711680, "shininess": 25, "bumpMap": "texture_bump", "bumpScale": -0.75 }
},
"phong_ben": {
"type": "MeshPhongMaterial",
"parameters": { "color": 1118481, "ambient": 1118481, "specular": 5601245, "shininess": 12, "bumpMap": "texture_bump_repeat", "bumpScale": 0.125, "envMaps": "cube_reflection", "reflectivity": 0.5 }
},
"phong_normal": {
"type": "MeshPhongMaterial",
"parameters": { "color": 1118481, "specular": 16777215, "shininess": 25, "envMap": "cube_reflection", "reflectivity": 0.1, "lightMap": "texture_ao", "normalMap": "texture_normal", "normalScale": [ 1, -1 ], "displacementMap": "texture_displacement", "displacementScale": 2.436143, "displacementBias": -0.428408 }
"parameters": { "color": 0, "specular": 16777215, "shininess": 25, "envMap": "cube_reflection", "reflectivity": 0.1, "lightMap": "texture_ao", "normalMap": "texture_normal", "normalScale": [ 1, -1 ], "displacementMap": "texture_displacement", "displacementScale": 2.436143, "displacementBias": -0.428408 }
},
"lambert_green": {
......@@ -465,6 +488,12 @@
"anisotropy": 4
},
"texture_bump_repeat": {
"url": "textures/water.jpg",
"repeat" : [ 20, 20 ],
"anisotropy": 4
},
"texture_normal": {
"url": "textures/normal/ninja/normal.jpg",
"anisotropy": 4
......@@ -518,15 +547,15 @@
"type" : "directional",
"direction" : [0,1,1],
"color" : 16777215,
"intensity" : 0.8
"intensity" : 1
},
"light2": {
"type" : "point",
"position": [0,0,0],
"color" : 16777215
"color" : 16777215,
"intensity" : 1.25
}
},
"fogs": {
......
......@@ -149,6 +149,10 @@
<script src="../build/three.min.js"></script>
<script src="js/loaders/ctm/lzma.js"></script>
<script src="js/loaders/ctm/ctm.js"></script>
<script src="js/loaders/ctm/CTMLoader.js"></script>
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
......@@ -230,6 +234,10 @@
renderer.domElement.style.position = "relative";
container.appendChild( renderer.domElement );
renderer.gammaInput = true;
renderer.gammaOutput = true;
renderer.physicallyBasedShading = true;
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
......
......@@ -58,15 +58,17 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
geometry, material, camera, fog,
texture, images,
light,
data, binLoader, jsonLoader,
counter_models, counter_textures,
total_models, total_textures,
result;
data = json;
var data = json;
binLoader = new THREE.BinaryLoader();
jsonLoader = new THREE.JSONLoader();
var binLoader = new THREE.BinaryLoader();
var jsonLoader = new THREE.JSONLoader();
var ctmLoader = new THREE.CTMLoader();
var useWorker, useBuffers;
counter_models = 0;
counter_textures = 0;
......@@ -123,7 +125,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
};
// the toplevel loader function, delegates to handle_children
// toplevel loader function, delegates to handle_children
function handle_objects() {
......@@ -273,7 +275,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
if ( o.properties !== undefined) {
if ( o.properties !== undefined ) {
for ( var key in o.properties ) {
......@@ -495,7 +497,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
g = data.geometries[ dg ];
if ( g.type == "bin_mesh" || g.type == "ascii_mesh" ) {
if ( g.type === "bin_mesh" || g.type === "ascii_mesh" || g.type === "ctm_mesh" ) {
counter_models += 1;
......@@ -541,6 +543,12 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
geometry = new THREE.IcosahedronGeometry( g.radius, g.subdivisions );
result.geometries[ dg ] = geometry;
} else if ( g.type === "ctm_mesh" ) {
useWorker = data.useWorker !== undefined ? data.useWorker : true;
useBuffers = data.useBuffers !== undefined ? data.useBuffers : true;
ctmLoader.load( get_url( g.url, data.urlBaseType ), create_callback( dg ), useWorker, useBuffers );
} else if ( g.type === "bin_mesh" ) {
binLoader.load( get_url( g.url, data.urlBaseType ), create_callback( dg ) );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册