0

我使用three.dart 框架开发了简单的项目。它启动并显示网页正常。但在 3-5 秒后,它会因未知错误而崩溃。Dart 编辑器和浏览器不显示崩溃的原因

这是一个代码:

import 'dart:html';
import 'dart:math' as Math;
import 'package:three/three.dart'; 

class MyClass {
  Element container;
  PerspectiveCamera camera;
  Scene scene;
  CanvasRenderer renderer;
  Mesh plane;
  num targetRotation;
  num targetRotationOnMouseDown;
  num windowHalfX;
  num windowHalfY;
  var evtSubscriptions = []; 

  void run() {
    init();
    animate(0);
  } 

  void init() {
    targetRotation = 0;
    targetRotationOnMouseDown = 0;
    windowHalfX = window.innerWidth / 2;
    windowHalfY = window.innerHeight / 2; 
    container = new Element.tag('div');
    document.body.nodes.add( container );
    Element info = new Element.tag('div');
    info.style.position = 'absolute';
    info.style.top = '10px';
    info.style.width = '100%';
    info.style.textAlign = 'center';
    info.innerHtml = 'Drag to spin the cube';
    container.nodes.add( info );

    scene = new Scene();
    camera = new PerspectiveCamera( 70.0, window.innerWidth / window.innerHeight, 1.0, 1000.0 );
    camera.position.y = 150.0;
    camera.position.z = 500.0;
    scene.add( camera ); 

    // Plane
    plane = new Mesh( new PlaneGeometry( 200.0, 200.0 ), null);
    scene.add( plane );

    renderer = new CanvasRenderer();
    renderer.setSize( window.innerWidth, window.innerHeight );
    container.nodes.add( renderer.domElement );
} 

void render() {
    renderer.render( scene, camera );
  } 

animate(num time) {
    window.requestAnimationFrame(animate);
    render();
  }
} 

void main() {
  new Canvas_Geometry_Cube().run();
}

如何修复崩溃?

4

2 回答 2

1

我发现了问题。它适用于 Web GL(不是画布)。

于 2013-10-07T19:27:48.567 回答
0

Sergio three.dart 可能需要一些工作来更新,自从在 pub 上发布最新版本以来已经有一段时间了。对不起。请随时在https://github.com/threeDart/three.dart网站上查看最新的分支或代码审查

于 2013-10-04T16:17:03.563 回答