收藏
回答

three.js模型开发者工具显示,真机预览无法显示?

框架类型 问题类型 操作系统 工具版本
小程序 Bug Windows 1.05.2106300
 function init() {
    camera = new THREE.PerspectiveCamera(45, canvas.width / canvas.height, 0.25100);
    camera.position.set(-5310);
    camera.lookAt(new THREE.Vector3(020));
    scene = new THREE.Scene();
    clock = new THREE.Clock();
    // lights
    var light = new THREE.HemisphereLight(0xffffff0x444444);
    light.position.set(0200);
    scene.add(light);
    light = new THREE.DirectionalLight(0xffffff);
    light.position.set(02010);
    scene.add(light);
     
    // model
    var loader = new THREE.GLTFLoader();
    wx.showLoading({
      title'模型加载中',
      masktrue
    })
    loader.load('https://threejs.org/examples/models/gltf/RobotExpressive/RobotExpressive.glb'function (gltf{ 
      wx.hideLoading()
      console.log('load modal success')
      model = gltf.scene;
      model.scale.set(4,4,4)
      scene.add(model);
      createGUI(model, gltf.animations)
    }, undefinedfunction (e{
      console.error(e);
      wx.hideLoading()
      wx.showToast({
        title'模型加载出错',
        icon:'error'
      })
    });
    renderer = new THREE.WebGLRenderer({
      antialiastrue
    });
    renderer.setPixelRatio(wx.getSystemInfoSync().pixelRatio);
    renderer.setSize(canvas.width, canvas.height);
    renderer.gammaOutput = true;
    renderer.gammaFactor = 2.2;


    const {
      OrbitControls
    } = registerOrbit(THREE)
    controls = new OrbitControls(camera, renderer.domElement);


    camera.position.set(5510);
    controls.update();
  }


以上是主要加载模型代码,在开发者工具是完全正常的,真机(iPhone8 plus)有时候无法显示,有时候打开调试模式,真机就能显示,有时候又不行,社区其他人也反馈过多个类似的问题,盼回复

回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容