mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
@@ -374,7 +374,10 @@ export class Mesh extends Asset {
|
||||
}
|
||||
|
||||
@property
|
||||
private _struct: IMeshStruct;
|
||||
private _struct: IMeshStruct = {
|
||||
vertexBundles: [],
|
||||
primitives: [],
|
||||
};
|
||||
|
||||
private _data: Uint8Array | null = null;
|
||||
|
||||
@@ -384,11 +387,6 @@ export class Mesh extends Asset {
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
|
||||
this._struct = {
|
||||
vertexBundles: [],
|
||||
primitives: [],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -308,7 +308,7 @@ export default class AnimationComponent extends Component {
|
||||
/**
|
||||
* @type {AnimationClip[]}
|
||||
*/
|
||||
@property
|
||||
@property({ type: [AnimationClip] })
|
||||
_clips = [];
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ export default class AnimationComponent extends Component {
|
||||
* @property currentClip
|
||||
* @type {AnimationClip}
|
||||
*/
|
||||
@property({type:AnimationClip})
|
||||
@property({ type:AnimationClip })
|
||||
currentClip = null;
|
||||
|
||||
/**
|
||||
@@ -333,7 +333,7 @@ export default class AnimationComponent extends Component {
|
||||
|
||||
_preview = false;
|
||||
|
||||
@property({type: Boolean})
|
||||
@property({ type: Boolean })
|
||||
get preview() {
|
||||
return this._preview;
|
||||
}
|
||||
@@ -383,7 +383,9 @@ export default class AnimationComponent extends Component {
|
||||
* @property clips
|
||||
* @type {AnimationClip[]}
|
||||
*/
|
||||
@property([AnimationClip])
|
||||
@property({
|
||||
type: [AnimationClip],
|
||||
})
|
||||
get clips() {
|
||||
return this._clips;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
executeInEditMode,
|
||||
executionOrder,
|
||||
menu,
|
||||
property
|
||||
property,
|
||||
} from '../../../core/data/class-decorator';
|
||||
import Vec3 from '../../../core/value-types/vec3';
|
||||
import { PhysicsBoxShape, PhysicsShape, PhysicsSphereShape } from './body';
|
||||
@@ -17,37 +17,39 @@ export class ColliderComponentBase extends PhysicsBasedComponent {
|
||||
@property
|
||||
private _center: Vec3 = new cc.Vec3(0, 0, 0);
|
||||
|
||||
constructor(shape: PhysicsShape) {
|
||||
constructor (shape: PhysicsShape) {
|
||||
super();
|
||||
this._center = new Vec3(0, 0, 0);
|
||||
this._shape = shape;
|
||||
}
|
||||
|
||||
public get body() {
|
||||
public get body () {
|
||||
return this._body;
|
||||
}
|
||||
|
||||
public onLoad() {
|
||||
public onLoad () {
|
||||
super.onLoad();
|
||||
this.center = this._center;
|
||||
}
|
||||
|
||||
public onEnable() {
|
||||
public onEnable () {
|
||||
super.onEnable();
|
||||
this._body!.addShape(this._shape);
|
||||
}
|
||||
|
||||
public onDisable() {
|
||||
public onDisable () {
|
||||
super.onDisable();
|
||||
this._body!.removeShape(this._shape);
|
||||
}
|
||||
|
||||
@property(Vec3)
|
||||
get center() {
|
||||
@property({
|
||||
type: Vec3,
|
||||
})
|
||||
get center () {
|
||||
return this._center;
|
||||
}
|
||||
|
||||
set center(value: Vec3) {
|
||||
set center (value: Vec3) {
|
||||
this._center = new Vec3(value.x, value.y, value.z);
|
||||
this._shape.center = value;
|
||||
}
|
||||
@@ -61,24 +63,26 @@ export class BoxColliderComponent extends ColliderComponentBase {
|
||||
@property
|
||||
private _size: Vec3 = new Vec3(0, 0, 0);
|
||||
|
||||
constructor() {
|
||||
constructor () {
|
||||
super(new PhysicsBoxShape(new Vec3(0, 0, 0)));
|
||||
}
|
||||
|
||||
public onLoad() {
|
||||
public onLoad () {
|
||||
super.onLoad();
|
||||
this.size = this._size;
|
||||
}
|
||||
|
||||
@property(Vec3)
|
||||
get size() {
|
||||
@property({
|
||||
type: Vec3,
|
||||
})
|
||||
get size () {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note, shall not specify size with component 0
|
||||
*/
|
||||
set size(value) {
|
||||
set size (value) {
|
||||
this._size = value;
|
||||
(this._shape as PhysicsBoxShape).size = this._size;
|
||||
if (this._body) {
|
||||
@@ -95,21 +99,21 @@ export class SphereColliderComponent extends ColliderComponentBase {
|
||||
@property
|
||||
private _radius: number = 0;
|
||||
|
||||
constructor() {
|
||||
constructor () {
|
||||
super(new PhysicsSphereShape(0));
|
||||
}
|
||||
|
||||
public onLoad() {
|
||||
public onLoad () {
|
||||
super.onLoad();
|
||||
this.radius = this._radius;
|
||||
}
|
||||
|
||||
@property
|
||||
get radius() {
|
||||
get radius () {
|
||||
return this._radius;
|
||||
}
|
||||
|
||||
set radius(value) {
|
||||
set radius (value) {
|
||||
this._radius = value;
|
||||
(this._shape as PhysicsSphereShape).radius = value;
|
||||
if (this._body) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
executeInEditMode,
|
||||
executionOrder,
|
||||
menu,
|
||||
property
|
||||
property,
|
||||
} from '../../../core/data/class-decorator';
|
||||
import { PhysicsMaterial } from '../../assets/physics/material';
|
||||
import { PhysicsBasedComponent } from './detail/physics-based-component';
|
||||
@@ -26,38 +26,40 @@ export class RigidBodyComponent extends PhysicsBasedComponent {
|
||||
@property
|
||||
private _angularDamping: number = NonRigidBodyProperties.angularDamping;
|
||||
|
||||
constructor() {
|
||||
constructor () {
|
||||
super();
|
||||
}
|
||||
|
||||
public get body() {
|
||||
public get body () {
|
||||
return this._body;
|
||||
}
|
||||
|
||||
public onLoad() {
|
||||
public onLoad () {
|
||||
super.onLoad();
|
||||
}
|
||||
|
||||
public onEnable() {
|
||||
public onEnable () {
|
||||
super.onEnable();
|
||||
this.mass = this._mass;
|
||||
this.linearDamping = this._linearDamping;
|
||||
this.angularDamping = this._angularDamping;
|
||||
}
|
||||
|
||||
public onDisable() {
|
||||
public onDisable () {
|
||||
super.onDisable();
|
||||
this.mass = NonRigidBodyProperties.mass;
|
||||
this.linearDamping = NonRigidBodyProperties.linearDamping;
|
||||
this.angularDamping = NonRigidBodyProperties.angularDamping;
|
||||
}
|
||||
|
||||
@property(PhysicsMaterial)
|
||||
get material() {
|
||||
@property({
|
||||
type: PhysicsMaterial,
|
||||
})
|
||||
get material () {
|
||||
return this._material;
|
||||
}
|
||||
|
||||
set material(value) {
|
||||
set material (value) {
|
||||
this._material = value;
|
||||
if (this._body) {
|
||||
this._body.material = this._material;
|
||||
@@ -65,11 +67,11 @@ export class RigidBodyComponent extends PhysicsBasedComponent {
|
||||
}
|
||||
|
||||
@property
|
||||
get mass() {
|
||||
get mass () {
|
||||
return this._mass;
|
||||
}
|
||||
|
||||
set mass(value) {
|
||||
set mass (value) {
|
||||
this._mass = value;
|
||||
if (this._body) {
|
||||
this._body.mass = value;
|
||||
@@ -77,11 +79,11 @@ export class RigidBodyComponent extends PhysicsBasedComponent {
|
||||
}
|
||||
|
||||
@property
|
||||
get linearDamping() {
|
||||
get linearDamping () {
|
||||
return this._linearDamping;
|
||||
}
|
||||
|
||||
set linearDamping(value) {
|
||||
set linearDamping (value) {
|
||||
this._linearDamping = value;
|
||||
if (this._body) {
|
||||
this._body.linearDamping = value;
|
||||
@@ -89,18 +91,18 @@ export class RigidBodyComponent extends PhysicsBasedComponent {
|
||||
}
|
||||
|
||||
@property
|
||||
get angularDamping() {
|
||||
get angularDamping () {
|
||||
return this._angularDamping;
|
||||
}
|
||||
|
||||
set angularDamping(value) {
|
||||
set angularDamping (value) {
|
||||
this._angularDamping = value;
|
||||
if (this._body) {
|
||||
this._body.angularDamping = value;
|
||||
}
|
||||
}
|
||||
|
||||
public pullTransform() {
|
||||
public pullTransform () {
|
||||
if (this._body) {
|
||||
this._body.pullTransform();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('cc.RenderableComponent')
|
||||
export class RenderableComponent extends Component {
|
||||
@property([Material])
|
||||
@property({
|
||||
type: [Material],
|
||||
})
|
||||
private _materials: Array<Material | null> = [];
|
||||
|
||||
constructor () {
|
||||
@@ -16,6 +18,7 @@ export class RenderableComponent extends Component {
|
||||
@property({
|
||||
type: [Material],
|
||||
displayName: 'Materials',
|
||||
default: [],
|
||||
})
|
||||
get sharedMaterials () {
|
||||
return this._materials;
|
||||
|
||||
@@ -36,7 +36,7 @@ import {ccclass} from '../core/data/class-decorator';
|
||||
* @private
|
||||
*/
|
||||
@ccclass('cc.Script')
|
||||
class Script extends Asset {
|
||||
export class Script extends Asset {
|
||||
}
|
||||
cc._Script = Script;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import { CCObject } from '../core/data/object';
|
||||
import {getClassName, value} from '../core/utils/js';
|
||||
import IDGenerator from '../core/utils/id-generator';
|
||||
import {ccclass, property} from '../core/data/class-decorator';
|
||||
import {Script} from '../assets';
|
||||
|
||||
let idGenerator = new IDGenerator('Comp');
|
||||
const IsOnEnableCalled = CCObject.Flags.IsOnEnableCalled;
|
||||
@@ -102,7 +103,7 @@ class Component extends CCObject {
|
||||
|
||||
@property({
|
||||
displayName: 'Script',
|
||||
type: cc._Script,
|
||||
type: Script,
|
||||
tooltip: CC_DEV && 'i18n:INSPECTOR.component.script'
|
||||
})
|
||||
get __scriptAsset () { return null; }
|
||||
|
||||
@@ -1022,10 +1022,13 @@ else {
|
||||
|
||||
try {
|
||||
if (__audioSupport.WEB_AUDIO) {
|
||||
__audioSupport.context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
|
||||
if(__audioSupport.DELAY_CREATE_CTX) {
|
||||
setTimeout(function(){ __audioSupport.context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); }, 0);
|
||||
}
|
||||
__audioSupport._context = null;
|
||||
Object.defineProperty(__audioSupport, 'context', {
|
||||
get () {
|
||||
if (this._context) return this._context;
|
||||
return this._context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch(error) {
|
||||
__audioSupport.WEB_AUDIO = false;
|
||||
|
||||
@@ -29,7 +29,6 @@ import debug from '../core/platform/CCDebug';
|
||||
|
||||
var __audioSupport = sys.__audioSupport;
|
||||
var formatSupport = __audioSupport.format;
|
||||
var context = __audioSupport.context;
|
||||
|
||||
function loadDomAudio (item, callback) {
|
||||
var dom = document.createElement('audio');
|
||||
@@ -70,6 +69,7 @@ function loadDomAudio (item, callback) {
|
||||
}
|
||||
|
||||
function loadWebAudio (item, callback) {
|
||||
const context = __audioSupport.context;
|
||||
if (!context)
|
||||
callback(new Error(debug.getError(4926)));
|
||||
|
||||
@@ -115,4 +115,4 @@ export default function downloadAudio (item, callback) {
|
||||
}
|
||||
}
|
||||
loader(item, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
bodyModel.material.setProperty('color', color);
|
||||
bodyModel.material.overridePipelineStates({ primitive: cc.GFXPrimitiveMode.LINE_LIST });
|
||||
return arrow;
|
||||
}
|
||||
};
|
||||
const createBorderPlane = (color, position, rotation) => {
|
||||
const borderPlane = new cc.Node('borderPlane');
|
||||
borderPlane.setPosition(position);
|
||||
@@ -112,7 +112,7 @@
|
||||
borderModel.material.setProperty('color', color);
|
||||
borderModel.material.overridePipelineStates({ primitive: cc.GFXPrimitiveMode.LINE_LIST });
|
||||
return borderPlane;
|
||||
}
|
||||
};
|
||||
|
||||
const moveTool = new cc.Node('moveTool');
|
||||
moveTool.parent = scene;
|
||||
@@ -125,7 +125,7 @@
|
||||
|
||||
let vel = cc.v3(), speed = 0.1;
|
||||
canv.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'i') vel.z = speed;
|
||||
if (e.key === 'i') vel.z = speed;
|
||||
else if (e.key === 'k') vel.z = -speed;
|
||||
else if (e.key === 'j') vel.x = speed;
|
||||
else if (e.key === 'l') vel.x = -speed;
|
||||
@@ -133,7 +133,7 @@
|
||||
else if (e.key === 'u') vel.y = -speed;
|
||||
});
|
||||
canv.addEventListener('keyup', (e) => {
|
||||
if (e.key === 'i') vel.z = 0;
|
||||
if (e.key === 'i') vel.z = 0;
|
||||
else if (e.key === 'k') vel.z = 0;
|
||||
else if (e.key === 'j') vel.x = 0;
|
||||
else if (e.key === 'l') vel.x = 0;
|
||||
|
||||
Reference in New Issue
Block a user