Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
matsurai25 committed Dec 22, 2016
0 parents commit ad335e6
Show file tree
Hide file tree
Showing 33 changed files with 1,063 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# バージョン管理対象外デフォルト指定
#

# 全般
*.tmp
*.bak
*.swp

# Linux 一般
*~

# Mac OS X 一般
._*
.AppleDesktop
.AppleDouble
.DS_Store
.Spotlight-V100
.Trashes
.localized
Icon

# Windows 一般
$RECYCLE.BIN/
Desktop.ini
Thumbs.db

node_modules
.sass-cache
npm-debug.log
dist
ZXPSignCmd
*.zxp
*.p12
config.cson
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# composition2json
アクティブなコンポジションをjsonで書き出します。

# usage
コンポジションを選択した状態でスクリプト->ファイルを指定してスクリプトを実行

# development

```
npm install
```
でインストール

```
npm start
```
でコンパイル + 変更のあるたびに書き出し直し

基本的にはESTKと併用する。
(ESTKでbundle.jsxを開いておく)
37 changes: 37 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';
const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const rimraf = require('rimraf');
const sequence = require('run-sequence');

const BUNDLENAME = 'bundle.jsx';
const DIST = './dist/';

gulp.task('default', () => {
sequence('clean', 'build', 'watch');
});

gulp.task('clean', (cb) => {
rimraf(DIST, cb);
});

gulp.task('build', () => {
browserify({
entries: ['./lib/entry.js']
})
.transform("require-globify")
.transform("babelify", {presets: ["es2015"]})
.bundle()
.on('error', function(e){
console.log(e.message);
console.log(e.stack);
this.emit("end");
})
.pipe(source(BUNDLENAME))
.pipe(gulp.dest(DIST));
});

gulp.task('watch', () => {
gulp.watch(['src/**/*.js','lib/**/*.js'], ['build']);
});
27 changes: 27 additions & 0 deletions lib/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

// make namespace
$.global.window = {}; // for escape error
$.global.C2J = global.C2J = {};

// make modern environment
$.global.Object = {};
try {
require('es5-shim/es5-shim.min.js');
require('es5-shim/es5-sham.min.js');
} catch (error) {
// ExtendScriptはすべてのグローバル変数を次回実行時も記憶している。
// es5-shimでグローバルのDateオブジェクトをprototype拡張するが、次回実行時も保持したままになっている。
// その関係で、2度目の読み込みでDate.prototype.toISOStringが例外を投げる。
$.writeln('Caught an error:', error);
}

$.global._ = window._ = require('underscore');
$.global.JSON = require('JSON2');

// class
require('./loader.js');

// start mainstream

require('../src/main.js');
19 changes: 19 additions & 0 deletions lib/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require('../src/class/Util.js');
require('../src/class/BaseObject.js');
require('../src/class/LayerObject.js');
require('../src/class/ItemObject.js');
require('../src/class/CollectionObject.js');
require('../src/class/PropertyBaseObject.js');
require('../src/class/AVLayerObject.js');
require('../src/class/AVItemObject.js');
require('../src/class/CompItemObject.js');
require('../src/class/FolderItemObject.js');
require('../src/class/FootageItemObject.js');
require('../src/class/FootageSourceObject.js');
require('../src/class/LayerCollectionObject.js');
require('../src/class/PropertyGroupObject.js');
require('../src/class/PropertyObject.js');
require('../src/class/SolidSourceObject.js');
require('../src/class/MarkerValueObject.js');

require('../src/class/**/*.js', {glob: true}); // require other files
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "composition2json",
"version": "1.0.0",
"description": "convert composition to json",
"scripts": {
"start": "gulp"
},
"author": "matsurai25",
"license": "MIT",
"dependencies": {
"JSON2": "^0.1.0",
"babel-preset-es2015": "^6.16.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"es5-shim": "^4.5.9",
"gulp": "^3.9.1",
"json-beautify": "^1.0.1",
"require-globify": "^1.4.1",
"rimraf": "^2.5.4",
"run-sequence": "^1.2.2",
"underscore": "^1.8.3",
"vinyl-source-stream": "^1.1.0"
}
}
33 changes: 33 additions & 0 deletions src/class/AVItemObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

class AVItemObject extends C2J.ItemObject {
constructor(obj) {
super(obj);

// native props
this.width = obj.width;
this.height = obj.height;
if(obj.pixelAspect != 1) this.pixelAspect = obj.pixelAspect;
this.frameRate = obj.frameRate;
if(obj.frameDuration != 1) this.frameDuration = obj.frameDuration;
this.duration = obj.duration;
if(obj.useProxy) this.useProxy = obj.useProxy;
if(obj.useProxy) this.proxySource = C2J.getObject(obj.proxySource);
// this.time = obj.time;
// this.usedIn = obj.usedIn;
if(!obj.hasVideo) this.hasVideo = obj.hasVideo;
if(obj.hasAudio) this.hasAudio = obj.hasAudio;
if(obj.footageMissing) this.footageMissing = obj.footageMissing;

// native methods
this.setProxy = obj.setProxy;
this.setProxyWithSequence = obj.setProxyWithSequence;
this.setProxyWithSolid = obj.setProxyWithSolid;
this.setProxyWithPlaceholder = obj.setProxyWithPlaceholder;
this.setProxyToNone = obj.setProxyToNone;

}

// methods
}
C2J.AVItemObject = AVItemObject;
80 changes: 80 additions & 0 deletions src/class/AVLayerObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
'use strict';

class AVLayerObject extends C2J.LayerObject {
constructor(obj) {
super(obj);

// native props
this.type = 'AVLayerObject';
this.source = C2J.getObject(obj.source);
if(!obj.isNameFromSource) this.isNameFromSource = obj.isNameFromSource;
this.height = obj.height;
this.width = obj.width;
// this.audioEnabled = obj.audioEnabled;
if(obj.motionBlur) this.motionBlur = obj.motionBlur;
if(!obj.effectsActive) this.effectsActive = obj.effectsActive;
if(obj.adjustmentLayer) this.adjustmentLayer = obj.adjustmentLayer;
if(obj.guideLayer) this.guideLayer = obj.guideLayer;
if(obj.threeDLayer) this.threeDLayer = obj.threeDLayer;
if(obj.threeDPerChar) this.threeDPerChar = obj.threeDPerChar;
if(obj.environmentLayer) this.environmentLayer = obj.environmentLayer;
// this.canSetCollapseTransformation = obj.canSetCollapseTransformation;
if(obj.collapseTransformation) this.collapseTransformation = obj.canSetCollapseTransformation ? obj.collapseTransformation : null;
if(obj.frameBlending) this.frameBlending = obj.frameBlending;
if(obj.frameBlending) this.frameBlendingType = obj.frameBlendingType;
// this.canSetTimeRemapEnabled = obj.canSetTimeRemapEnabled;
if(obj.canSetTimeRemapEnabled) this.timeRemapEnabled = obj.timeRemapEnabled;
// this.hasAudio = obj.hasAudio;
// this.audioActive = obj.audioActive;
if(obj.blendingMode !== BlendingMode.NORMAL) this.blendingMode = obj.blendingMode;
if(obj.preserveTransparency) this.preserveTransparency = obj.preserveTransparency;
if(obj.trackMatteType !== TrackMatteType.NO_TRACK_MATTE) this.trackMatteType = obj.trackMatteType;
if(obj.isTrackMatte) this.isTrackMatte = obj.isTrackMatte;
if(obj.hasTrackMatte) this.hasTrackMatte = obj.hasTrackMatte;
// this.quality = obj.quality;
if(obj.autoOrient !== AutoOrientType.NO_AUTO_ORIENT) this.autoOrient = obj.autoOrient;
// this.samplingQuality = obj.samplingQuality;

// native methods
// this.audioActiveAtTime = obj.audioActiveAtTime;
// this.calculateTransformFromPoints = obj.calculateTransformFromPoints;
// this.replaceSource = obj.replaceSource;
// this.sourceRectAtTime = obj.sourceRectAtTime;
// this.openInViewer = obj.openInViewer;


// PropertyObjects

var marker = C2J.getObject(obj("ADBE Marker"));
if(!_.isEmpty(marker) && obj("ADBE Marker").isModified) this.marker = marker;

var timeRemap = C2J.getObject(obj("ADBE Time Remapping"));
if(!_.isEmpty(timeRemap) && obj("ADBE Time Remapping").isModified) this.timeRemap = timeRemap;

var motionTrackers = C2J.getObject(obj("ADBE MTrackers"));
if(!_.isEmpty(motionTrackers)) this.motionTrackers = motionTrackers;

var transform = C2J.getObject(obj("ADBE Transform Group"));
if(!_.isEmpty(transform)) this.transform = transform;

var layerStyle = C2J.getObject(obj("ADBE Layer Styles"));
if(!_.isEmpty(layerStyle)) this.layerStyle = layerStyle;

var geometryOptions = C2J.getObject(obj("ADBE Geometry Options"));
if(!_.isEmpty(geometryOptions)) this.geometryOptions = geometryOptions;

var audio = C2J.getObject(obj("ADBE Audio Group"));
if(!_.isEmpty(audio)) this.audio = audio;

var effects = C2J.getObject(obj("ADBE Effect Parade"));
if(!_.isEmpty(effects) && obj("ADBE Effect Parade").isModified) this.effects = effects;

var masks = C2J.getObject(obj("ADBE Mask Parade"));
if(!_.isEmpty(masks) && obj("ADBE Mask Parade").isModified) this.masks = masks;

}

// methods
}

C2J.AVLayerObject = AVLayerObject;
29 changes: 29 additions & 0 deletions src/class/BaseObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

class BaseObject {
constructor() {
}

getProps(){
var props = [];
for (var key in this) {
if (!this.hasOwnProperty(key) || typeof this[key] == 'function') {
continue;
}
props.push(key);
}
return props;
}
getMethods(){
var methods = [];
for (var key in this) {
if (!this.hasOwnProperty(key) || typeof this[key] !== 'function') {
continue;
}
methods.push(key);
}
return methods;
}
}

C2J.BaseObject = BaseObject;
17 changes: 17 additions & 0 deletions src/class/CameraLayerObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

class CameraLayerObject extends C2J.AVLayerObject {
constructor(obj) {
super(obj);

this.type = 'CameraLayerObject';
// PropertyObjects
var cameraOptions = C2J.getObject(obj("ADBE Camera Options Group"));
if(obj("ADBE Camera Options Group").isModified) this.cameraOptions = cameraOptions;

}

// methods
}

C2J.CameraLayerObject = CameraLayerObject;
15 changes: 15 additions & 0 deletions src/class/CollectionObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

class CollectionObject extends C2J.BaseObject {
constructor(obj) {
super(obj);

// native props
this.length = obj.length;

}

// methods
}

C2J.CollectionObject = CollectionObject;
50 changes: 50 additions & 0 deletions src/class/CompItemObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';

class CompItemObject extends C2J.AVItemObject {
constructor(obj) {
super(obj);

// native props

this.frameDuration = obj.frameDuration;
if(obj.dropFrame) this.dropFrame = obj.dropFrame;
// this.workAreaStart = obj.workAreaStart;
// this.workAreaDuration = obj.workAreaDuration;
// this.numLayers = obj.numLayers;
if(obj.hideShyLayers) this.hideShyLayers = obj.hideShyLayers;
if(obj.motionBlur) this.motionBlur = obj.motionBlur;
if(obj.draft3d) this.draft3d = obj.draft3d;
if(obj.frameBlending) this.frameBlending = obj.frameBlending;
if(obj.preserveNestedFrameRate) this.preserveNestedFrameRate = obj.preserveNestedFrameRate;
if(obj.preserveNestedResolution) this.preserveNestedResolution = obj.preserveNestedResolution;
// this.bgColor = obj.bgColor;
// this.activeCamera = obj.activeCamera;
this.displayStartTime = obj.displayStartTime;
// this.resolutionFactor = obj.resolutionFactor;
// this.shutterAngle = obj.shutterAngle;
// this.shutterPhase = obj.shutterPhase;
// this.motionBlurSamplesPerFrame = obj.motionBlurSamplesPerFrame;
// this.motionBlurAdaptiveSampleLimit = obj.motionBlurAdaptiveSampleLimit;
// this.layers = obj.layers;
// this.selectedLayers = obj.selectedLayers;
// this.selectedProperties = obj.selectedProperties;
this.renderer = obj.renderer;
// this.renderers = obj.renderers;

// native methods
// this.duplicate = obj.duplicate;
// this.layer = obj.layer;
// this.openInViewer = obj.openInViewer;

this.layers = [];
for (var i = 1; i <= obj.numLayers; i++) {
var o = obj.layer(i);
this.layers.push(C2J.getObject(o));
}

}

// methods
}

C2J.CompItemObject = CompItemObject;
Loading

0 comments on commit ad335e6

Please # to comment.