mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 11:02:40 +08:00
Merge branch '3d' of https://github.com/cocos-creator/engine into 3d
This commit is contained in:
@@ -8,16 +8,29 @@ import {
|
||||
import Vec3 from '../../../core/value-types/vec3';
|
||||
import { vec3 } from '../../../core/vmath';
|
||||
import { BoxShapeBase, ShapeBase, SphereShapeBase } from '../../physics/api';
|
||||
import { createBoxShape, createSphereShape } from '../../physics/instance';
|
||||
import { createBoxShape, createSphereShape, ERigidBodyType } from '../../physics/instance';
|
||||
import { PhysicsBasedComponent } from './detail/physics-based-component';
|
||||
|
||||
export class ColliderComponentBase extends PhysicsBasedComponent {
|
||||
protected _shapeBase: ShapeBase | null = null;
|
||||
|
||||
@property
|
||||
private _triggered: boolean = false;
|
||||
@property
|
||||
get isTrigger () { return this._triggered; }
|
||||
set isTrigger (value) {
|
||||
this._triggered = value;
|
||||
if (this._body) {
|
||||
let type = this._triggered ? ERigidBodyType.DYNAMIC : ERigidBodyType.STATIC;
|
||||
this._body.setType(type);
|
||||
this._body.setIsTrigger(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The center of the collider, in local space.
|
||||
*/
|
||||
@property({type: Vec3})
|
||||
@property({ type: Vec3 })
|
||||
get center () {
|
||||
return this._center;
|
||||
}
|
||||
@@ -44,6 +57,7 @@ export class ColliderComponentBase extends PhysicsBasedComponent {
|
||||
if (this._enabled) {
|
||||
this.onEnable();
|
||||
}
|
||||
this.isTrigger = this._triggered;
|
||||
}
|
||||
|
||||
public onEnable () {
|
||||
@@ -92,7 +106,7 @@ export class BoxColliderComponent extends ColliderComponentBase {
|
||||
* The size of the box, in local space.
|
||||
* @note Shall not specify size with component 0.
|
||||
*/
|
||||
@property({type: Vec3})
|
||||
@property({ type: Vec3 })
|
||||
get size () {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
Vendored
+7
-2
@@ -1,6 +1,7 @@
|
||||
import { Vec3, Quat } from '../../core/value-types';
|
||||
import { Node } from '../../scene-graph';
|
||||
import { RaycastResult } from './raycast-result';
|
||||
import { ERigidBodyType } from './instance';
|
||||
|
||||
export interface IRaycastOptions {
|
||||
collisionFilterMask?: number;
|
||||
@@ -59,6 +60,10 @@ export class PhysicsWorldBase {
|
||||
export class RigidBodyBase {
|
||||
constructor (options?: ICreateBodyOptions);
|
||||
|
||||
/**获取/设置刚体类型 : ERigidBodyType*/
|
||||
getType (): ERigidBodyType;
|
||||
setType (v: ERigidBodyType): void;
|
||||
|
||||
addShape (shape: ShapeBase): void;
|
||||
|
||||
removeShape (shape: ShapeBase): void;
|
||||
@@ -128,7 +133,7 @@ export class RigidBodyBase {
|
||||
|
||||
getUserData (): any;
|
||||
|
||||
setUserData(data: any): void;
|
||||
setUserData (data: any): void;
|
||||
}
|
||||
|
||||
export class ShapeBase {
|
||||
@@ -140,7 +145,7 @@ export class ShapeBase {
|
||||
|
||||
getUserData (): any;
|
||||
|
||||
setUserData(data: any): void;
|
||||
setUserData (data: any): void;
|
||||
}
|
||||
|
||||
export class SphereShapeBase extends ShapeBase {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import CANNON from 'cannon';
|
||||
import { Quat, Vec3 } from '../../core/value-types';
|
||||
import { quat, vec3 } from '../../core/vmath';
|
||||
import { AfterStepCallback, BeforeStepCallback,
|
||||
import {
|
||||
AfterStepCallback, BeforeStepCallback,
|
||||
BoxShapeBase,
|
||||
ConstraintBase, DistanceConstraintBase,
|
||||
ICollisionCallback, ICollisionEvent,
|
||||
@@ -9,9 +10,11 @@ import { AfterStepCallback, BeforeStepCallback,
|
||||
ILockConstraintOptions,
|
||||
IPointToPointConstraintOptions,
|
||||
IRaycastOptions, LockConstraintBase, PhysicsWorldBase,
|
||||
PointToPointConstraintBase, RigidBodyBase, ShapeBase, SphereShapeBase } from './api';
|
||||
PointToPointConstraintBase, RigidBodyBase, ShapeBase, SphereShapeBase
|
||||
} from './api';
|
||||
import { RaycastResult } from './raycast-result';
|
||||
import { stringfyQuat, stringfyVec3 } from './util';
|
||||
import { ERigidBodyType } from './instance';
|
||||
|
||||
const defaultCannonMaterial = new CANNON.Material('');
|
||||
const defaultCannonContactMaterial = new CANNON.ContactMaterial(
|
||||
@@ -32,7 +35,7 @@ export class CannonWorld implements PhysicsWorldBase {
|
||||
constructor () {
|
||||
this._cannonWorld = new CANNON.World();
|
||||
setWrap<PhysicsWorldBase>(this._cannonWorld, this);
|
||||
this._cannonWorld.allowSleep = true;
|
||||
// this._cannonWorld.allowSleep = true;
|
||||
this._cannonWorld.gravity.set(0, -9.81, 0);
|
||||
this._cannonWorld.broadphase = new CANNON.NaiveBroadphase();
|
||||
this._cannonWorld.defaultMaterial = defaultCannonMaterial;
|
||||
@@ -216,6 +219,14 @@ export class CannonRigidBody implements RigidBodyBase {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
public getType (): ERigidBodyType {
|
||||
return this._cannonBody.type;
|
||||
}
|
||||
|
||||
public setType (v: ERigidBodyType): void {
|
||||
this._cannonBody.type = v;
|
||||
}
|
||||
|
||||
public addShape (shape: CannonShape) {
|
||||
const index = this._shapes.length;
|
||||
this._shapes.push(shape);
|
||||
@@ -296,7 +307,7 @@ export class CannonRigidBody implements RigidBodyBase {
|
||||
}
|
||||
|
||||
public setIsTrigger (value: boolean): void {
|
||||
this._cannonBody.collisionResponse = value;
|
||||
this._cannonBody.collisionResponse = !value;
|
||||
}
|
||||
|
||||
public getVelocity (): Vec3 {
|
||||
|
||||
@@ -3,6 +3,12 @@ import { BoxShapeBase, ICreateBodyOptions, PhysicsWorldBase, RigidBodyBase, Sphe
|
||||
import { BoxShape, PhysicsWorld, RigidBody, SphereShape } from './impl-selector';
|
||||
import { RaycastResult } from './raycast-result';
|
||||
|
||||
export enum ERigidBodyType {
|
||||
DYNAMIC = 1,
|
||||
STATIC = 2,
|
||||
KINEMATIC = 4
|
||||
}
|
||||
|
||||
export function createPhysicsWorld (): PhysicsWorldBase {
|
||||
return new PhysicsWorld();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class WrappedInfo {
|
||||
public direction = 1;
|
||||
public stopped = true;
|
||||
public iterations = 0;
|
||||
public frameIndex: number = NaN;
|
||||
public frameIndex: number = undefined as unknown as number;
|
||||
|
||||
constructor (info?: WrappedInfo) {
|
||||
if (info) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
// @ts-check
|
||||
import {ccclass, property} from '../core/data/class-decorator';
|
||||
import {addon} from '../core/utils/js';
|
||||
// import {addon} from '../core/utils/js';
|
||||
import { Asset } from './asset';
|
||||
import { EventTargetFactory } from '../core/event/event-target-factory';
|
||||
|
||||
@@ -121,7 +121,8 @@ export class ImageAsset extends EventTargetFactory(Asset) {
|
||||
|
||||
public reset (data: ImageSource) {
|
||||
if (!(data instanceof HTMLElement)) {
|
||||
this._nativeData = Object.create(data);
|
||||
// this._nativeData = Object.create(data);
|
||||
this._nativeData = data;
|
||||
this._onDataComplete();
|
||||
} else {
|
||||
this._nativeData = data;
|
||||
@@ -220,8 +221,8 @@ export class ImageAsset extends EventTargetFactory(Asset) {
|
||||
* !#en
|
||||
* This event is emitted when the asset is loaded
|
||||
*
|
||||
* @event load
|
||||
* @event loads
|
||||
*/
|
||||
addon(ImageAsset.prototype, EventTarget.prototype);
|
||||
// addon(ImageAsset.prototype, EventTarget.prototype);
|
||||
|
||||
cc.ImageAsset = ImageAsset;
|
||||
|
||||
@@ -8,7 +8,7 @@ type Constructor<T = {}> = new(...args: any[]) => T;
|
||||
|
||||
export type IEventTargetCallback = (...args: any[]) => void;
|
||||
|
||||
class Empty { protected constructor () {}; }
|
||||
class Empty { protected constructor () {} }
|
||||
|
||||
export function EventTargetFactory<Base extends Constructor<{}>> (b?: Base) {
|
||||
let base = b;
|
||||
|
||||
@@ -517,6 +517,32 @@ export class NodeEventProcessor {
|
||||
_cachedArray.length = 0;
|
||||
}
|
||||
|
||||
public hasEventListener (type: string) {
|
||||
let has = false;
|
||||
if (this.bubblingTargets) {
|
||||
has = this.bubblingTargets.hasEventListener(type);
|
||||
}
|
||||
if (!has && this.capturingTargets) {
|
||||
has = this.capturingTargets.hasEventListener(type);
|
||||
}
|
||||
return has;
|
||||
}
|
||||
|
||||
public targetOff (target: string | Object) {
|
||||
if (this.capturingTargets) {
|
||||
this.capturingTargets.targetOff(target);
|
||||
}
|
||||
|
||||
if (this.touchListener && !_checkListeners(this.node, _touchEvents)) {
|
||||
eventManager.removeListener(this.touchListener);
|
||||
this.touchListener = null;
|
||||
}
|
||||
if (this.mouseListener && !_checkListeners(this.node, _mouseEvents)) {
|
||||
eventManager.removeListener(this.mouseListener);
|
||||
this.mouseListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
// EVENT TARGET
|
||||
|
||||
private _checknSetupSysEvent (type: string) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { UITransformComponent } from '../3d/ui/components/ui-transfrom-component';
|
||||
import { ccclass, property } from '../core/data/class-decorator';
|
||||
import Event from '../core/event/event';
|
||||
import { eventManager } from '../core/platform/event-manager';
|
||||
import { EventType } from '../core/platform/event-manager/event-enum';
|
||||
import { Mat4, Quat, Vec3 } from '../core/value-types';
|
||||
import Size from '../core/value-types/size';
|
||||
@@ -773,7 +775,7 @@ class Node extends BaseNode {
|
||||
this.uiTransfromComp!.setContentSize(size, height);
|
||||
}
|
||||
|
||||
// Event
|
||||
// Event: maybe remove
|
||||
|
||||
public on (type: string | EventType, callback: Function, target?: Object, useCapture?: any) {
|
||||
this._eventProcessor.on(type, callback, target, useCapture);
|
||||
@@ -783,17 +785,33 @@ class Node extends BaseNode {
|
||||
this._eventProcessor.off(type, callback, target, useCapture);
|
||||
}
|
||||
|
||||
public once (type, callback, target, useCapture) {
|
||||
public once (type: string, callback: Function, target?: Object, useCapture?: any) {
|
||||
this._eventProcessor.once(type, callback, target, useCapture);
|
||||
}
|
||||
|
||||
public emit (type, ...args: any[]) {
|
||||
public emit (type: string, ...args: any[]) {
|
||||
this._eventProcessor.emit(type, ...args);
|
||||
}
|
||||
|
||||
public dispatchEvent (event) {
|
||||
public dispatchEvent (event: Event) {
|
||||
this._eventProcessor.dispatchEvent(event);
|
||||
}
|
||||
|
||||
public hasEventListener (type: string){
|
||||
return this._eventProcessor.hasEventListener(type);
|
||||
}
|
||||
|
||||
public targetOff (target: string | Object) {
|
||||
this._eventProcessor.targetOff(target);
|
||||
}
|
||||
|
||||
public pauseSystemEvents (recursive: boolean) {
|
||||
eventManager.pauseTarget(this, recursive);
|
||||
}
|
||||
|
||||
public resumeSystemEvents (recursive: boolean) {
|
||||
eventManager.resumeTarget(this, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
if (CC_EDITOR) {
|
||||
|
||||
@@ -179,6 +179,10 @@ else {
|
||||
defineMacro('CC_SUPPORT_JIT', !(CC_WECHATGAME || CC_QQPLAY || CC_RUNTIME));
|
||||
}
|
||||
|
||||
//#begin test code for wechat
|
||||
// _global['CC_SUPPORT_JIT'] = false;
|
||||
//#end
|
||||
|
||||
//
|
||||
|
||||
if (CC_DEV) {
|
||||
|
||||
+13
-13
@@ -83,19 +83,19 @@ async function _doBundle (options: IBuildOptions) {
|
||||
|
||||
code = generated.code;
|
||||
|
||||
console.log(`Doing uglify...`);
|
||||
|
||||
const minifyOutput = minify(code, {
|
||||
compress: {
|
||||
global_defs: options.globalDefines,
|
||||
},
|
||||
});
|
||||
if (minifyOutput.error) {
|
||||
console.error(minifyOutput.error.stack);
|
||||
return null;
|
||||
} else {
|
||||
code = minifyOutput.code;
|
||||
}
|
||||
// console.log(`Doing uglify...`);
|
||||
|
||||
// const minifyOutput = minify(code, {
|
||||
// compress: {
|
||||
// global_defs: options.globalDefines,
|
||||
// },
|
||||
// });
|
||||
// if (minifyOutput.error) {
|
||||
// console.error(minifyOutput.error.stack);
|
||||
// return null;
|
||||
// } else {
|
||||
// code = minifyOutput.code;
|
||||
// }
|
||||
|
||||
return {
|
||||
code,
|
||||
|
||||
Reference in New Issue
Block a user