Files
cocos4/playground/src/custom-effect.js
T
pandamicro 3240dba206 Component rename for new standard and 2d compatibility (#7103)
* Rename ui related components

* Rename files

* Remove Useless errors

* Fix sealed names

* Fix sealed global variables

* Fix circular reference

* Refactor more component names

* Rename particle and animation related component

* export scene and models sub module in renderer

* Rename ModelComponents to Model

* Refactor LightComponents to Light

* Refactor CameraComponent to Camera

* Refactor ConstraintComponents to Constraint and rename physics comps

* Cleanup and fix issues

* Small fixes

* Refactor Model to MeshRenderer

* Final touch

* Fix data class export

* Better deprecation to cover all old usage

* Simpler and better deprecation with js.setClassAlias

* Fix ci

* Fix editor issue
2020-09-02 15:31:49 +08:00

33 lines
962 B
JavaScript

cc.AssetLibrary.init({
libraryPath: 'library',
rawAssetsBase: 'library',
rawAssets: {
assets: {
// https://github.com/cocos-creator/example-3d/blob/master/demo02/assets/effects/test.effect
"97051ce4-0cc9-4ae0-a584-d73943d7c11a": ["test", "cc.EffectAsset"]
}
}
});
const scene = new cc.Scene();
const cameraNode = new cc.Node('Camera');
cameraNode.parent = scene;
cameraNode.setPosition(6, 0, 2);
cameraNode.setRotationFromEuler(0, 70, 0);
cameraNode.addComponent(cc.Camera);
cameraNode.addComponent(FirstPersonCamera);
const modelNode = new cc.Node('test');
modelNode.parent = scene;
const modelComp = modelNode.addComponent('cc.MeshRenderer');
modelComp.mesh = cc.utils.createMesh(cc.primitives.sphere());
cc.director.runSceneImmediate(scene);
cc.loader.loadRes('test', cc.EffectAsset, (err, effect) => {
const material = new cc.Material();
material.initialize({ effectAsset: effect });
modelComp.material = material;
});