1
我很新的BabylonJS和我創建了一個自定義的網一樣,(我不知道這是否是正確的方式):Javascript方法在BabylonJS不工作與自定義網
function DragSphere() {
this.sphere = BABYLON.Mesh.CreateSphere("sphere", 15, 2, scene);
this.sphere.material = new BABYLON.StandardMaterial("sphereMat", scene);
...
return (this.sphere);
}
DragSphere.prototype.setRGBColor = function(r, g, b) {
this.sphere.material.diffuseColor = new BABYLON.Color3(r/255, g/255, b/255);
}
所以我想用我的DragSphere
的SetRGBColor
方法來更新它的顏色,但是瀏覽器似乎並不同意我:
Uncaught TypeError: sphere.setRGBColor is not a function
嗨,thx的響應,但我沒有使用TypeScript ^^ –
好吧 - 同樣適用於JavaScript(雖然我不認爲你總是得到在構造函數返回錯誤消息)。你有沒有嘗試刪除返回語句? @boehm_s – Mark
我會試試這個,因爲我的項目在另一臺電腦上,謝謝;) –