mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 11:31:59 +08:00
@@ -8,8 +8,6 @@ export interface IPropertyInfo {
|
||||
type: number; // auto-extracted if not specified
|
||||
value?: number[] | string;
|
||||
displayName?: string;
|
||||
tech?: number;
|
||||
pass?: number;
|
||||
}
|
||||
export interface IPassInfo {
|
||||
program: string;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
import { CameraComponent } from './camera-component';
|
||||
import AnimationComponent from './animation-component';
|
||||
import LightComponent from './light-component';
|
||||
import ModelComponent from './model-component';
|
||||
import { ModelComponent } from './model-component';
|
||||
import SkinningModelComponent from './skinning-model-component';
|
||||
import SkyboxComponent from './skybox-component';
|
||||
import { BoxColliderComponent, SphereColliderComponent } from './physics/collider-component';
|
||||
|
||||
@@ -26,7 +26,7 @@ import { Model } from '../../renderer/scene/model';
|
||||
import { ccclass, property, menu, executionOrder, executeInEditMode } from '../../core/data/class-decorator';
|
||||
import { Mesh } from '../assets/mesh';
|
||||
import Enum from '../../core/value-types/enum';
|
||||
import RenderableComponent from './renderable-component';
|
||||
import { RenderableComponent } from './renderable-component';
|
||||
|
||||
/**
|
||||
* !#en Shadow projection mode
|
||||
@@ -85,7 +85,7 @@ let ModelShadowCastingMode = Enum({
|
||||
@executionOrder(100)
|
||||
@menu('Components/ModelComponent')
|
||||
@executeInEditMode
|
||||
export default class ModelComponent extends RenderableComponent {
|
||||
export class ModelComponent extends RenderableComponent {
|
||||
|
||||
/**
|
||||
* @type {Mesh}
|
||||
|
||||
@@ -4,7 +4,7 @@ import gfx from '../../../../renderer/gfx';
|
||||
import { Material } from '../../../assets/material';
|
||||
import { RecyclePool } from '../../../memop';
|
||||
import Particle from '../particle';
|
||||
import RenderableComponent from '../../renderable-component';
|
||||
import { RenderableComponent } from '../../renderable-component';
|
||||
import { Enum, Vec2 } from '../../../../core/value-types';
|
||||
import { property, ccclass, executeInEditMode } from '../../../../core/data/class-decorator';
|
||||
import { Space } from '../particle-general-function';
|
||||
|
||||
@@ -5,9 +5,9 @@ import { Material } from '../assets/material';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('cc.RenderableComponent')
|
||||
export default class RenderableComponent extends Component {
|
||||
export class RenderableComponent extends Component {
|
||||
@property([Material])
|
||||
private _materials: Material[] = [];
|
||||
private _materials: Array<Material | null> = [];
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
@@ -59,7 +59,7 @@ export default class RenderableComponent extends Component {
|
||||
* !#ch 返回相对应序号的材质
|
||||
* @param {Number} idx - Look for the material list number
|
||||
*/
|
||||
public getMaterial (idx) {
|
||||
public getMaterial (idx: number): Material | null {
|
||||
if (idx < 0 || idx >= this._materials.length || this._materials[idx] == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ export default class RenderableComponent extends Component {
|
||||
return this._materials[idx];
|
||||
}
|
||||
|
||||
public getSharedMaterial (idx) {
|
||||
public getSharedMaterial (idx: number): Material | null {
|
||||
if (idx < 0 || idx >= this._materials.length) {
|
||||
return null;
|
||||
}
|
||||
@@ -94,12 +94,12 @@ export default class RenderableComponent extends Component {
|
||||
return this.getSharedMaterial(0);
|
||||
}
|
||||
|
||||
public setMaterial (material, index) {
|
||||
public setMaterial (material: Material | null, index: number) {
|
||||
this._materials[index] = material;
|
||||
this._onMaterialModified(index, material);
|
||||
}
|
||||
|
||||
public _onMaterialModified (index, material) {
|
||||
public _onMaterialModified (index: number, material: Material | null) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
// @ts-check
|
||||
import { mat4 } from '../../core/vmath';
|
||||
import ModelComponent from './model-component';
|
||||
import { ModelComponent } from './model-component';
|
||||
import * as renderer from '../../renderer/index';
|
||||
import { ccclass, property, executionOrder, menu,executeInEditMode } from '../../core/data/class-decorator';
|
||||
import * as utils from '../misc/utils';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>spec-scroll-view</title>
|
||||
<title>simple</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||
<style>
|
||||
@@ -59,17 +59,16 @@
|
||||
|
||||
const texture = createTexture(cc.game.canvas.getElementsByTagName('img'));
|
||||
|
||||
const material = new cc.Material();
|
||||
material.setDefines({ USE_COLOR: true });
|
||||
// parsed effect file is embedded in cocos/3d/builtin/effects.js
|
||||
material.effectName = 'builtin-effect-unlit';
|
||||
material.setProperty('mainTexture', texture);
|
||||
|
||||
const len = 50;
|
||||
const models = [], passes = [];
|
||||
const color = cc.color()
|
||||
const color = cc.color();
|
||||
for (let i = 0; i < len; i++) {
|
||||
const material = new cc.Material();
|
||||
material.setDefines({ USE_COLOR: true });
|
||||
// parsed effect file is embedded in cocos/3d/builtin/effects.js
|
||||
material.effectName = 'builtin-effect-unlit';
|
||||
material.setProperty('mainTexture', texture);
|
||||
passes.push(material.passes[0]);
|
||||
|
||||
const modelNode = new cc.Node(`${i}`);
|
||||
modelNode.parent = scene;
|
||||
const modelCom = modelNode.addComponent('cc.ModelComponent');
|
||||
@@ -77,6 +76,7 @@
|
||||
modelCom.mesh = cc.utils.createMesh(cc.primitives[geomList[i % geomList.length]]());
|
||||
modelNode.setPosition(0, 0, i * 2);
|
||||
models.push(modelNode);
|
||||
passes.push(modelCom.material.passes[0]);
|
||||
}
|
||||
const handle = passes[0].getHandle('color');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user