2013-10-03 31 views
0

我使用three.dart框架開發了簡單的項目。它啓動並顯示網頁確定。但是3-5秒後它會崩潰並出現未知錯誤。飛鏢編輯器和瀏覽器不顯示爲什麼墜毀Three.dart「Hello World」項目中的崩潰

這裏的原因是代碼:

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(); 
} 

如何修復崩潰?

+1

請在https://github.com/threeDart/three.dart/issues上提供代碼錯誤 –

回答

1

我發現了這個問題。它適用於Web GL(不是畫布)。

0

Sergio three.dart可能需要一些工作才能更新,因爲在pub上發佈了最新版本已經有一段時間了。抱歉。請隨時結帳https://github.com/threeDart/three.dart網站上的最新分支或代碼審查

+0

我使用「最新」分支。 – Sergio