簡體   English   中英

無法訪問成員數據Three.js TypeScript

[英]Can't access member data Three.js TypeScript

我正在使用來自DefinitelyTyped和TypeScript的three.d.ts。 我有以下代碼

class WoodStyle extends THREE.MeshBasicMaterial{
    putTexture(image: any){
        super.map=image;
    }
    constructor(){
        LoadImage().then(putTexture);
        super();
    }
}

在其中加載圖像,然后使用新圖像更新材質。 但是,當我嘗試編譯代碼時,它顯示了一個錯誤: 2340 Only public and protected methods of the base class are accessible via the 'super' keyword 我做錯了什么?

訪問繼承的屬性時,請使用this

class WoodStyle extends THREE.MeshBasicMaterial{
    putTexture(image: any){
        this.map=image;
    }
    constructor(){
        LoadImage().then(putTexture);
        super();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM