threejs editor源碼解析1


threejs editor源碼解析1

今天先看看 

 

 

這個功能的實現

 

這個實現就是用了  javascript signals 框架 異步通信 這么做就是為了解耦 渲染和邏輯 分離 這個跟vuejs一樣   

找到editor\js\commands\SetPositionCommand.js  這個文件 發布消息的

execute: function () {

        this.object.position.copy( this.newPosition );
        this.object.updateMatrixWorld( true );
        this.editor.signals.objectChanged.dispatch( this.object );

    },

然后接收消息

是在viewport.js

signals.objectChanged.add( function ( object ) {

        if ( editor.selected === object ) {

            selectionBox.setFromObject( object );

        }

        if ( object.isPerspectiveCamera ) {

            object.updateProjectionMatrix();

        }

        if ( editor.helpers[ object.id ] !== undefined ) {

            editor.helpers[ object.id ].update();

        }

        render();

    } );

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM