Merge branch '3d-v1.0.0' of https://github.com/cocos-creator/engine into 3d-v1.0.0

This commit is contained in:
jerrywwl
2019-07-19 18:12:19 +08:00
30 changed files with 501 additions and 142 deletions
@@ -42,6 +42,7 @@ import { IMeshStruct, Mesh } from '../assets/mesh';
import { Skeleton } from '../assets/skeleton';
import { LCA, mapBuffer } from '../misc/utils';
import { SkinningModelComponent } from './skinning-model-component';
import { AnimationComponent } from '../../components';
const repeat = (n: number) => n - Math.floor(n);
const batch_id: IGFXAttribute = { name: GFXAttributeName.ATTR_BATCH_ID, format: GFXFormat.R32F, isNormalized: false };
@@ -55,8 +56,6 @@ export class SkinningModelUnit {
public mesh: Mesh | null = null;
@property(Skeleton)
public skeleton: Skeleton | null = null;
@property(Node)
public skinningRoot: Node | null = null;
@property(Material)
public material: Material | null = null;
@property
@@ -85,7 +84,6 @@ export class SkinningModelUnit {
if (!comp) { return; }
this.mesh = comp.mesh;
this.skeleton = comp.skeleton;
this.skinningRoot = comp.skinningRoot;
this.material = comp.getSharedMaterial(0);
}
get copyFrom () {
@@ -209,25 +207,19 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent {
}
public cookSkeletons () {
// find lowest common ancestor as the new skinning root
let lca: Node | null = null;
for (const unit of this.units) {
if (!unit || !unit.skinningRoot) { continue; }
const cur = unit.skinningRoot;
if (!lca) { lca = cur; continue; }
lca = LCA(lca, cur);
}
this._skinningRoot = lca;
if (!lca) { console.warn('illegal skinning roots'); return; }
// find the lowest AnimationComponent node as the new skinning root
let root: Node | null = this.node;
while (root && !root.getComponent(AnimationComponent)) { root = root.parent; }
if (!root) { console.warn('skinning model component must be put under animation component'); return; }
this._skinningRoot = root;
// merge joints accordingly
const skeleton = new Skeleton();
const bindposes: Mat4[] = [];
for (const unit of this.units) {
if (!unit || !unit.skeleton || !unit.skinningRoot) { continue; }
if (!unit || !unit.skeleton) { continue; }
const partial = unit.skeleton;
const prefix = getPrefix(lca, unit.skinningRoot);
for (let i = 0; i < partial.joints.length; i++) {
const path = concatPath(prefix, partial.joints[i]);
const path = partial.joints[i];
const idx = skeleton.joints.findIndex((p) => p === path);
if (idx >= 0) { continue; }
skeleton.joints.push(path);
@@ -276,11 +268,9 @@ export class BatchedSkinningModelComponent extends SkinningModelComponent {
const unitLen = this.units.length;
for (let i = 0; i < unitLen; i++) {
const unit = this.units[i];
if (!unit || !unit.skeleton || !unit.skinningRoot) { continue; }
const prefix = getPrefix(this._skinningRoot, unit.skinningRoot);
if (!unit || !unit.skeleton) { continue; }
jointIndexMap[i] = unit.skeleton.joints.map((j) => {
const path = concatPath(prefix, j);
return this._skeleton!.joints.findIndex((ref) => path === ref);
return this._skeleton!.joints.findIndex((ref) => j === ref);
});
}
-9
View File
@@ -33,21 +33,12 @@ export * from './framework';
export * from './memop';
import * as geometry from './geom-utils';
import * as utils from './misc/utils';
import * as primitives from './primitive';
export * from './ui';
// hidden
// export { createRaycastResult } from './physics/instance';
export {
utils,
primitives,
geometry,
};
cc.geometry = geometry;
cc.primitives = primitives;
cc.utils = utils;
/// PHYSICS EXPORT ///
export * from './physics/export-api';
+14
View File
@@ -0,0 +1,14 @@
import { instantiate } from '../impl-selector';
import { CannonRigidBody } from './cannon-body';
import { CannonWorld } from './cannon-world';
import { CannonBoxShape } from './shapes/cannon-box-shape';
import { CannonSphereShape } from './shapes/cannon-sphere-shape';
if (CC_PHYSICS_CANNON) {
instantiate(
CannonBoxShape,
CannonSphereShape,
CannonRigidBody,
CannonWorld,
);
}
+15
View File
@@ -0,0 +1,15 @@
import { instantiate } from '../impl-selector';
import { BuiltInBody } from './builtin-body';
import { BuiltInWorld } from './builtin-world';
import { BuiltinBoxShape } from './shapes/builtin-box-shape';
import { BuiltinSphereShape } from './shapes/builtin-sphere-shape';
if (CC_PHYSICS_BUILT_IN) {
instantiate(
BuiltinBoxShape,
BuiltinSphereShape,
BuiltInBody,
BuiltInWorld,
);
}
+9 -15
View File
@@ -24,9 +24,6 @@ import { CannonWorld } from './cannon/cannon-world';
import { CannonBoxShape } from './cannon/shapes/cannon-box-shape';
import { CannonSphereShape } from './cannon/shapes/cannon-sphere-shape';
// Ammo
// import { AmmoBoxShape, AmmoRaycastResult, AmmoRigidBody, AmmoSphereShape, AmmoWorld, } from './ammo-impl';
// built-in
import { BuiltInBody } from './cocos/builtin-body';
import { BuiltInWorld } from './cocos/builtin-world';
@@ -38,16 +35,13 @@ export let SphereShape: typeof CannonSphereShape | typeof BuiltinSphereShape;
export let RigidBody: typeof CannonRigidBody | typeof BuiltInBody;
export let PhysicsWorld: typeof CannonWorld | typeof BuiltInWorld;
if (CC_PHYSICS_CANNON) {
BoxShape = CannonBoxShape;
SphereShape = CannonSphereShape;
RigidBody = CannonRigidBody;
PhysicsWorld = CannonWorld;
} else if (CC_PHYSICS_AMMO) {
// TODO : 选择AMMO
} else if (CC_PHYSICS_BUILT_IN) {
BoxShape = BuiltinBoxShape;
SphereShape = BuiltinSphereShape;
RigidBody = BuiltInBody;
PhysicsWorld = BuiltInWorld;
export function instantiate (
boxShape: typeof BoxShape,
sphereShape: typeof SphereShape,
body: typeof RigidBody,
world: typeof PhysicsWorld) {
BoxShape = boxShape;
SphereShape = sphereShape;
RigidBody = body;
PhysicsWorld = world;
}
@@ -3,8 +3,7 @@
* @category animation
*/
import { AnimationClip, AnimationState } from '../animation';
import { CrossFade } from '../animation/cross-fade';
import { Component } from '../components/component';
import { ccclass, executeInEditMode, executionOrder, menu, property } from '../core/data/class-decorator';
import { Event, EventTarget } from '../core/event';
import { CallbacksInvoker, ICallbackTable } from '../core/event/callbacks-invoker';
@@ -13,7 +12,9 @@ import { warnID } from '../core/platform/CCDebug';
import * as ArrayUtils from '../core/utils/array';
import { createMap } from '../core/utils/js-typed';
import { ccenum } from '../core/value-types/enum';
import { Component } from './component';
import { AnimationClip } from './animation-clip';
import { AnimationState } from './animation-state';
import { CrossFade } from './cross-fade';
/**
* @en The event type supported by Animation
+1
View File
@@ -652,6 +652,7 @@ export class AnimationState extends Playable {
}
private _sampleEvents (wrapInfo: WrappedInfo) {
const length = this._clip.eventGroups.length;
let direction = wrapInfo.direction;
let eventIndex = this._clip.getEventGroupIndexAtRatio(wrapInfo.ratio);
if (eventIndex < 0) {
+1
View File
@@ -12,3 +12,4 @@ export * from './skeletal-animation-clip';
export * from './animation-manager';
export * from './animation-state';
export * from './cubic-spline-value';
export * from './animation-component';
+1 -1
View File
@@ -8,7 +8,7 @@ import { SkinningModelComponent } from '../3d/framework/skinning-model-component
import { ccclass } from '../core/data/class-decorator';
import { getClassName } from '../core/utils/js';
import { Quat, Vec3 } from '../core/value-types';
import { mat4, quat, vec3 } from '../core/vmath';
import { quat, vec3 } from '../core/vmath';
import { Node } from '../scene-graph';
import { AnimationClip, ICurveData, IObjectCurveData, IPropertyCurve } from './animation-clip';
import { IPropertyCurveData } from './animation-curve';
-1
View File
@@ -31,4 +31,3 @@
export { Component } from './component';
export { EventHandler } from './component-event-handler';
export {default as MissingScript} from './missing-script';
export { AnimationComponent } from './animation-component';
-4
View File
@@ -16,8 +16,6 @@ import { GFXSampler } from './sampler';
import { GFXShader } from './shader';
import { GFXTexture } from './texture';
import { GFXTextureView } from './texture-view';
import { WebGLGFXDevice } from './webgl/webgl-device';
import { WebGL2GFXDevice } from './webgl2/webgl2-device';
export { GFXAttributeName, GFXFormat, GFXPrimitiveMode } from './define';
@@ -34,7 +32,5 @@ cc.GFXPipelineLayout = GFXPipelineLayout;
cc.GFXPipelineState = GFXPipelineState;
cc.GFXCommandBuffer = GFXCommandBuffer;
cc.GFXQueue = GFXQueue;
cc.WebGLGFXDevice = WebGLGFXDevice;
cc.WebGL2GFXDevice = WebGL2GFXDevice;
Object.assign(cc, GFXDefines);
+1 -1
View File
@@ -82,7 +82,7 @@ export class SkinningModel extends Model {
public bindSkeleton (skeleton: Skeleton | null, skinningRoot: Node | null) {
this._skeleton = skeleton;
if (!skeleton || !skinningRoot) { return; }
this._transform = skinningRoot.parent!;
this._transform = skinningRoot;
this._applyJointTexture(skeleton.getBindposeTexture(this._device));
}
+27
View File
@@ -0,0 +1,27 @@
/*
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
export * from '../cocos/animation';
+20
View File
@@ -0,0 +1,20 @@
import '../predefine';
import '../cocos/legacy';
// LOAD ENGINE CORE
export * from '../cocos/core';
export * from '../cocos/scene-graph';
import * as renderer from '../cocos/renderer';
export { renderer };
cc.renderer = renderer;
export * from '../cocos/assets';
export * from '../cocos/load-pipeline';
export * from '../cocos/components';
export * from '../cocos/3d';
export * from '../cocos/gfx';
import '../cocos/pipeline';
export * from '../extensions/ccpool/node-pool';
const cclegacy = cc;
export { cclegacy };
+3
View File
@@ -0,0 +1,3 @@
import { WebGLGFXDevice } from '../cocos/gfx/webgl/webgl-device';
cc.WebGLGFXDevice = WebGLGFXDevice;
+3
View File
@@ -0,0 +1,3 @@
import { WebGL2GFXDevice } from '../cocos/gfx/webgl2/webgl2-device';
cc.WebGL2GFXDevice = WebGL2GFXDevice;
+2
View File
@@ -0,0 +1,2 @@
// import '../cocos/3d/physics/ammo/instantiate';
+3
View File
@@ -0,0 +1,3 @@
import '../cocos/3d/physics/cocos/instantiate';
export * from '../cocos/3d/physics/export-api';
+3
View File
@@ -0,0 +1,3 @@
import '../cocos/3d/physics/cannon/instantiate';
export * from '../cocos/3d/physics/export-api';
+6
View File
@@ -0,0 +1,6 @@
import * as primitives from '../cocos/3d/primitive';
export {
primitives,
};
cc.primitives = primitives;
+2
View File
@@ -0,0 +1,2 @@
export * from '../cocos/tween';
+8 -55
View File
@@ -1,56 +1,9 @@
/*
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// PREDEFINE
/**
* @hidden
*/
import './predefine';
import './cocos/legacy';
// LOAD ENGINE CORE
export * from './cocos/core';
export * from './cocos/scene-graph';
import * as renderer from './cocos/renderer';
export { renderer };
cc.renderer = renderer;
export * from './cocos/assets';
export * from './cocos/animation';
export * from './cocos/load-pipeline';
export * from './cocos/components';
export * from './cocos/3d';
export * from './cocos/gfx';
import './cocos/pipeline';
export * from './extensions/ccpool/node-pool';
const cclegacy = cc;
export { cclegacy };
export * from './cocos/tween';
// export default cc;
export * from './exports/base';
export * from './exports/animation';
export * from './exports/gfx-webgl';
export * from './exports/gfx-webgl2';
export * from './exports/primitives';
export * from './exports/tween';
export * from './exports/physics-builtin';
export * from './exports/physics-cannon';
+3 -2
View File
@@ -72,9 +72,10 @@
"require-dir": "0.3.0",
"rollup": "^1.15.6",
"rollup-plugin-babel": "^4.1.0-1",
"rollup-plugin-commonjs": "^9.1.6",
"rollup-plugin-commonjs": "10.0.1",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-uglify": "^6.0.2",
"rollup-watch": "^4.3.1",
"tfig": "^1.0.20",
+78 -12
View File
@@ -2,15 +2,48 @@
import * as fs from 'fs-extra';
import * as ps from 'path';
import yargs from 'yargs';
import { build, IBuildOptions, IFlags, Physics, Platform } from './build-engine';
import { build, enumeratePhysicsReps, enumeratePlatformReps, IBuildOptions, IFlags, parsePhysics, parsePlatform } from './build-engine';
yargs.option('platform', { type: 'string', alias: 'p' });
yargs.option('physics', { type: 'string', alias: 'py' });
yargs.option('flags', { type: 'array', alias: 'f' });
yargs.option('destination', { type: 'string', alias: 'd' });
yargs.option('excludes', { type: 'array', alias: 'e' });
yargs.options('sourcemap', {});
yargs.boolean('compress');
yargs.help();
yargs.option('platform', {
type: 'string',
alias: 'p',
description: 'Target platform.',
demandOption: true,
choices: enumeratePlatformReps(),
});
yargs.option('physics', {
type: 'string',
alias: 'py',
description: 'Physics engine to use.',
choices: enumeratePhysicsReps(),
});
yargs.option('flags', {
type: 'array',
alias: 'f',
description: 'Engine flags.',
});
yargs.option('destination', {
type: 'string',
alias: 'd',
description: 'Output path.',
});
yargs.option('excludes', {
type: 'array',
alias: 'e',
description: '(Expired!)',
});
yargs.options('sourcemap', {
choices: [
'inline',
true,
],
description: 'Source map generation options',
});
yargs.option('compress', {
type: 'boolean',
description: 'Whether to compress compiled engine.',
});
const flags: IFlags = {};
const argvFlags = yargs.argv.flags as (string[] | undefined);
@@ -20,23 +53,32 @@ if (argvFlags) {
const sourceMap = yargs.argv.sourcemap === 'inline' ? 'inline' : !!yargs.argv.sourcemap;
const moduleEntries = yargs.argv._;
if (moduleEntries.length === 0) {
console.log(`No module entry specified, default module entries will be used.`);
moduleEntries.push(...getDefaultModuleEntries());
}
const options: IBuildOptions = {
moduleEntries,
compress: yargs.argv.compress as (boolean | undefined),
inputPath: './index.ts',
outputPath: yargs.argv.destination as string,
excludes: yargs.argv.excludes as string[],
sourcemap: sourceMap,
flags,
platform: yargs.argv.platform as (Platform | undefined),
physics: yargs.argv.physics as (Physics | undefined),
};
if (yargs.argv.platform) {
options.platform = parsePlatform(yargs.argv.platform as unknown as string);
}
if (yargs.argv.physics) {
options.physics = parsePhysics(yargs.argv.physics as unknown as string);
}
build(options).then(
(result) => {
console.log(`Build successful.`);
fs.ensureDirSync(ps.dirname(options.outputPath));
fs.writeFileSync(options.outputPath, result.code);
console.log(`With map? ${!!result.map}`);
if (result.map) {
fs.writeFileSync(`${options.outputPath}.map`, result.map);
}
@@ -45,3 +87,27 @@ build(options).then(
console.error(`Build failed, reason:\n ${reason.stack}`);
},
);
function getDefaultModuleEntries () {
type ModuleDivision = any; // import('../../scripts/module-division/tools/division-config').ModuleDivision;
type GroupItem = any; // import('../../scripts/module-division/tools/division-config').GroupItem;
type Item = any; // import('../../scripts/module-division/tools/division-config').Item;
const isGroupItem = (item: Item): item is GroupItem => {
return 'options' in item;
};
const divisionConfig: ModuleDivision = require('../../scripts/module-division/division-config.json');
const result = [];
for (const item of divisionConfig.items) {
if (item.required || item.default) {
if (isGroupItem(item)) {
result.push(item.options[item.defaultOption || 0].entry);
} else {
// @ts-ignore
result.push(item.entry);
}
}
}
return result;
}
+54 -18
View File
@@ -1,4 +1,5 @@
import { dirname, relative } from 'path';
import { existsSync } from 'fs';
import { dirname, join, normalize, relative } from 'path';
import { rollup } from 'rollup';
// @ts-ignore
import babel from 'rollup-plugin-babel';
@@ -7,17 +8,16 @@ import commonjs from 'rollup-plugin-commonjs';
// @ts-ignore
import json from 'rollup-plugin-json';
// @ts-ignore
import multiEntry from 'rollup-plugin-multi-entry';
// @ts-ignore
import resolve from 'rollup-plugin-node-resolve';
// @ts-ignore
import { uglify } from 'rollup-plugin-uglify';
const { excludes } = require('../plugin/rollup-plugin-excludes');
// @ts-ignore
import { excludes } from '../plugin/rollup-plugin-excludes';
interface IBaseOptions {
/**
* 引擎入口模块。
*/
inputPath: string;
moduleEntries: string[];
/**
* 指定输出路径。
@@ -79,18 +79,22 @@ export async function build (options: IBuildOptions) {
return await _internalBuild(Object.assign(options, {globalDefines}));
}
function resolveModuleEntry (moduleEntry: string) {
return normalize(`${__dirname}/../../exports/${moduleEntry}.ts`);
}
async function _internalBuild (options: IAdvancedOptions) {
console.log(`Build-engine options: ${JSON.stringify(options, undefined, 2)}`);
const doUglify = !!options.compress;
const rollupPlugins = [
multiEntry(),
excludes({
modules: options.excludes,
}),
resolve({
extensions: ['.js', '.ts', '.json'],
jsnext: true,
main: true,
}),
json({
@@ -161,8 +165,14 @@ async function _internalBuild (options: IAdvancedOptions) {
const outputPath = options.outputPath;
const sourcemapFile = options.sourcemapFile || `${options.outputPath}.map`;
const moduleEntries = options.moduleEntries.map(resolveModuleEntry);
for (const moduleEntry of moduleEntries) {
if (!existsSync(moduleEntry)) {
console.error(`Cannot find engine module ${moduleEntry}`);
}
}
const rollupBuild = await rollup({
input: options.inputPath,
input: moduleEntries,
plugins: rollupPlugins,
});
const generated = await rollupBuild.generate({
@@ -190,9 +200,35 @@ async function _internalBuild (options: IAdvancedOptions) {
}
}
export type Platform = 'universal' | 'editor' | 'preview' | 'build' | 'test';
export enum Platform {
universal,
editor,
preview,
build,
test,
}
export type Physics = 'cannon' | 'ammo' | 'builtin';
export function enumeratePlatformReps () {
return Object.values(Platform).filter((value) => typeof value === 'string');
}
export function parsePlatform (rep: string) {
return Reflect.get(Platform, rep);
}
export enum Physics {
cannon,
ammo,
builtin,
}
export function enumeratePhysicsReps () {
return Object.values(Physics).filter((value) => typeof value === 'string');
}
export function parsePhysics (rep: string) {
return Reflect.get(Physics, rep);
}
export interface IFlags {
jsb?: boolean;
@@ -231,14 +267,14 @@ interface IGlobaldefines {
// tslint:disable-next-line: no-shadowed-variable
function getGlobalDefs (platform?: Platform, physics?: Physics, flags?: IFlags): object {
platform = platform || 'universal';
platform = platform || Platform.universal;
const PLATFORM_MACROS = ['CC_EDITOR', 'CC_PREVIEW', 'CC_BUILD', 'CC_TEST'];
const FLAGS = ['jsb', 'runtime', 'wechatgame', 'wechatgameSub', 'qqplay', 'debug', 'nativeRenderer'];
const platformMacro = 'CC_' + platform.toUpperCase();
if (PLATFORM_MACROS.indexOf(platformMacro) === -1 && platform !== 'universal') {
const platformMacro = ('CC_' + Platform[platform]).toUpperCase();
if (PLATFORM_MACROS.indexOf(platformMacro) === -1 && platform !== Platform.universal) {
throw new Error(`Unknown platform ${platform}.`);
}
const result: IGlobaldefines = {};
@@ -270,19 +306,19 @@ function getGlobalDefs (platform?: Platform, physics?: Physics, flags?: IFlags):
result.CC_PHYSICS_BUILT_IN = false;
switch (physics) {
case 'cannon':
case Physics.cannon:
result.CC_PHYSICS_CANNON = true;
result.CC_PHYSICS_AMMO = false;
result.CC_PHYSICS_BUILT_IN = false;
break;
case 'ammo':
case Physics.ammo:
result.CC_PHYSICS_CANNON = false;
result.CC_PHYSICS_AMMO = true;
result.CC_PHYSICS_BUILT_IN = false;
break;
case 'builtin':
case Physics.builtin:
result.CC_PHYSICS_CANNON = false;
result.CC_PHYSICS_AMMO = false;
result.CC_PHYSICS_BUILT_IN = true;
+1 -1
View File
@@ -12,7 +12,7 @@
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./out", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
@@ -0,0 +1,60 @@
{
"$schema": "./tools/division-config-schema.json",
"items": [
{
"name": "Base",
"required": true,
"entry": "base",
"default": true
},
{
"name": "Animation",
"entry": "animation",
"default": true
},
{
"name": "GFX",
"required": true,
"options": [
{
"name": "WebGL 1.0",
"entry": "gfx-webgl"
},
{
"name": "WebGL 2.0",
"entry": "gfx-webgl2"
}
],
"default": true,
"defaultOption": 0
},
{
"name": "Primitives",
"entry": "primitives",
"default": true
},
{
"name": "Physics",
"options": [
{
"name": "Built-in",
"entry": "physics-builtin"
},
{
"name": "cannon.js",
"entry": "physics-cannon"
},
{
"name": "ammo.js",
"entry": "physics-ammo"
}
],
"required": true,
"defaultOption": 0
},
{
"name": "tween.js Adapter",
"entry": "tween"
}
]
}
@@ -0,0 +1,98 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"GroupItem": {
"additionalProperties": false,
"properties": {
"default": {
"description": "If true, this field indicates the item is marked as bundled by default.",
"type": "boolean"
},
"defaultOption": {
"description": "Indicates the n-th option is selected by default if the item is marked as bundled.\nDefaults to 0.",
"type": "number"
},
"description": {
"description": "Item description.",
"type": "string"
},
"name": {
"description": "Item name.",
"type": "string"
},
"options": {
"description": "Options.",
"items": {
"additionalProperties": false,
"properties": {
"description": {
"description": "Option description.",
"type": "string"
},
"entry": {
"description": "Entry of the option.",
"type": "string"
},
"name": {
"description": "Name of the option.",
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"required": {
"description": "Whether if this item is required to provide.",
"type": "boolean"
}
},
"type": "object"
},
"SimpleItem": {
"additionalProperties": false,
"properties": {
"default": {
"description": "If true, this field indicates the item is marked as bundled by default.",
"type": "boolean"
},
"description": {
"description": "Item description.",
"type": "string"
},
"entry": {
"description": "Entry to the module.",
"type": "string"
},
"name": {
"description": "Item name.",
"type": "string"
},
"required": {
"description": "Whether if this item is required to provide.",
"type": "boolean"
}
},
"type": "object"
}
},
"properties": {
"items": {
"description": "Items.",
"items": {
"anyOf": [
{
"$ref": "#/definitions/SimpleItem"
},
{
"$ref": "#/definitions/GroupItem"
}
]
},
"type": "array"
}
},
"type": "object"
}
@@ -0,0 +1,68 @@
// tslint:disable:interface-name
export interface ModuleDivision {
/**
* Items.
*/
items: Item[];
}
interface BaseItem {
/**
* Item name.
*/
name: string;
/**
* Item description.
*/
description?: string;
/**
* Whether if this item is required to provide.
*/
required?: boolean;
/**
* If true, this field indicates the item is marked as bundled by default.
*/
default?: boolean;
}
export interface SimpleItem extends BaseItem {
/**
* Entry to the module.
*/
entry: string;
}
export interface GroupItem extends BaseItem {
/**
* Options.
*/
options: Array<{
/**
* Name of the option.
*/
name: string;
/**
* Entry of the option.
*/
entry: string;
/**
* Option description.
*/
description?: string;
}>;
/**
* Indicates the n-th option is selected by default if the item is marked as bundled.
* Defaults to 0.
*/
defaultOption?: number;
}
export type Item = SimpleItem | GroupItem;
@@ -0,0 +1,6 @@
const { execSync } = require('child_process');
const { join } = require('path');
const input = join(__dirname, 'division-config.ts');
const output = join(__dirname, 'division-config-schema.json');
execSync(`typescript-json-schema ${input} ModuleDivision -o ${output} --noExtraProps`);