Three.js 我有一台I型搅拌机';我正在尝试导入,但我可以';我看不出来
另一个文件:Three.js 我有一台I型搅拌机';我正在尝试导入,但我可以';我看不出来,three.js,Three.js,另一个文件: class _the_thinkrium_scene { // private constructor() { THREE.Scene.prototype.thinkrium_scene = this; THREE.Scene.prototype.thinkrium_scene.scene = new THREE.Scene(); THREE.Scene.prototype.thinkrium_scene.cam
class _the_thinkrium_scene {
// private
constructor() {
THREE.Scene.prototype.thinkrium_scene = this;
THREE.Scene.prototype.thinkrium_scene.scene = new THREE.Scene();
THREE.Scene.prototype.thinkrium_scene.camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 1000 );
THREE.Scene.prototype.thinkrium_scene.renderer = new THREE.WebGLRenderer({ antialias: true });
THREE.Scene.prototype.thinkrium_scene.renderer.setPixelRatio(window.devicePixelRatio);
THREE.Scene.prototype.thinkrium_scene.renderer.shadowMapEnabled = true;
THREE.Scene.prototype.thinkrium_scene.loading_manager = new THREE.LoadingManager();
THREE.Scene.prototype.thinkrium_scene.loader = new THREE.ColladaLoader();
THREE.Scene.prototype.thinkrium_scene.renderer.setClearColor(0xccccee);
THREE.Scene.prototype.thinkrium_scene.renderer.setSize(window.innerWidth, window.innerHeight);
THREE.Scene.prototype.thinkrium_scene.add_lights();
document.getElementById("container").appendChild(this.renderer.domElement);
THREE.Scene.prototype.thinkrium_scene.scene.add(this.camera);
THREE.Scene.prototype.thinkrium_scene.camera.position.set( 0, 2, 3 );
THREE.Scene.prototype.thinkrium_scene.camera.lookAt(0, 0, 0);
THREE.Scene.prototype.thinkrium_scene.load("themes/TheThinkrium/js/front_page/peterweb.dae");
}
// add_lights
// params: none
// functions: adds the lights to the scene
// returns: none
add_lights() {
THREE.Scene.prototype.thinkrium_scene.ambientLight = new THREE.AmbientLight(0xffffff);
THREE.Scene.prototype.thinkrium_scene.scene.add(
THREE.Scene.prototype.thinkrium_scene.ambientLight
);
}
// loader_setup
// params: object - three js scene context
// functions: loads the model from blender
// returns: none
loader_setup(context) {
var animations = context.animations;
var avatar = context.scene;
avatar.traverse( function ( node ) {
if ( node.isSkinnedMesh ) {
node.frustumCulled = false;
}
} );
var mixer = new THREE.AnimationMixer( avatar );
mixer.clipAction( animations[ 0 ] ).play();
console.log(THREE.Scene.prototype.thinkrium_scene);
THREE.Scene.prototype.thinkrium_scene.scene.add(avatar);
}
// loader_pretext
// params: xhr - the loading info
// functions : uses the xhr to describe how much information is left to load
// returns: none
loader_pretext(xhr) {
console.log(Math.floor((xhr.loaded / xhr.totalSize) * 100));
}
// loading_errors
// params: error - error context
// functions : logs errors to debug
// returns : none
loading_errors(err) {
console.log(err);
}
// load
// params: name - the name of the model
// functions: loads the model
// returns: none
load(name) {
THREE.Scene.prototype.thinkrium_scene.loader.load(
name,
THREE.Scene.prototype.thinkrium_scene.loader_setup,
THREE.Scene.prototype.thinkrium_scene.loader_pretext,
THREE.Scene.prototype.thinkrium_scene.loading_errors
);
}
// get_renderer
// params: none
// functions : gets the renderer
// returns: renderer
get_renderer() {
return THREE.Scene.prototype.thinkrium_scene.renderer;
}
// get_renderer
// params: none
// functions : gets the renderer
// returns: renderer
get_scene() {
return THREE.Scene.prototype.thinkrium_scene.scene;
}
// get_renderer
// params: none
// functions : gets the renderer
// returns: renderer
get_camera() {
return THREE.Scene.prototype.thinkrium_scene.camera;
}
}
我无法让我的模型出现在场景中,我想这是因为我失去了背景
但是当我把这个原型输入到console.log时,它就全都在那里了
最初我将THREE.Scene.prototype.thinkrium_场景作为this对象,但当我进入回调时,我失去了范围
我将
这个
对象原型化为三个场景
,但这似乎并不重要。我似乎无法将上下文绑定到任何上下文以从加载程序回调中获取this对象。哇,这是一些难以阅读的代码。你一定很喜欢打字。这些台词是怎么回事
"using strict"
/*
*
* standards :
*
* params are in the form of camelCase
* local vars are in the form of '_' i.e. these_are_vars
*
* class definitions are in the form of "_name"
* class declarations are in the form of "name"
*
* public and private vars are defined
*
*
* notations :
*
* function_name {}
* params : value - definition
* params : value - definition
* functions : definition
* returns : value - definition
*
*
*
*/
// main {}
// params : none
// functions : operates as the main entry point for the thinkrium scene
// returns : nothing
function main() {
var scene = new _the_thinkrium_scene();
animate( scene.get_renderer(), scene.get_scene(), scene.get_camera() );
window.onresize = resize(scene.get_renderer());
}
// animate
// params: none
// functions: sets up the request animation frame
// returns: none
function animate( theRenderer, theScene, theCamera) {
window.requestAnimationFrame(function(theRenderer, theScene, theCamera) {
});
theRenderer.render( theScene, theCamera );
};
// resize
// params: none
// functions: resizes the screen
// return: none
function resize(_renderer) {
_renderer.setSize(window.innerWidth, window.innerHeight);
}
window.onload = main();
看起来您正在为每个场景初始化渲染器?应该只有一个
代码的其余部分似乎还可以(就我在字母丛林中所能看到的),我怀疑没有错误消息?
可能您正在导出的模型非常小,甚至非常大?尝试设置刻度
如果只添加一个带有立方计量的3.0网格,会发生什么?这是可见的吗?哇,这是一些难以阅读的代码。你一定很喜欢打字。这些台词是怎么回事
"using strict"
/*
*
* standards :
*
* params are in the form of camelCase
* local vars are in the form of '_' i.e. these_are_vars
*
* class definitions are in the form of "_name"
* class declarations are in the form of "name"
*
* public and private vars are defined
*
*
* notations :
*
* function_name {}
* params : value - definition
* params : value - definition
* functions : definition
* returns : value - definition
*
*
*
*/
// main {}
// params : none
// functions : operates as the main entry point for the thinkrium scene
// returns : nothing
function main() {
var scene = new _the_thinkrium_scene();
animate( scene.get_renderer(), scene.get_scene(), scene.get_camera() );
window.onresize = resize(scene.get_renderer());
}
// animate
// params: none
// functions: sets up the request animation frame
// returns: none
function animate( theRenderer, theScene, theCamera) {
window.requestAnimationFrame(function(theRenderer, theScene, theCamera) {
});
theRenderer.render( theScene, theCamera );
};
// resize
// params: none
// functions: resizes the screen
// return: none
function resize(_renderer) {
_renderer.setSize(window.innerWidth, window.innerHeight);
}
window.onload = main();
看起来您正在为每个场景初始化渲染器?应该只有一个
代码的其余部分似乎还可以(就我在字母丛林中所能看到的),我怀疑没有错误消息?
可能您正在导出的模型非常小,甚至非常大?尝试设置刻度
如果只添加一个带有立方计量的3.0网格,会发生什么?那是可见的吗?我没有意识到,但它没有运行的原因是我没有正确呼叫我的皇家空军。。。。我很感激它我没有意识到,但它没有运行的原因是我没有正确地呼叫我的皇家空军。。。。我很感激