diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc561b1 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a554b7 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# composition2json +アクティブなコンポジションをjsonで書き出します。 + +# usage +コンポジションを選択した状態でスクリプト->ファイルを指定してスクリプトを実行 + +# development + +``` +npm install +``` +でインストール + +``` +npm start +``` +でコンパイル + 変更のあるたびに書き出し直し + +基本的にはESTKと併用する。 +(ESTKでbundle.jsxを開いておく) diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..2d42d3d --- /dev/null +++ b/gulpfile.js @@ -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']); +}); diff --git a/lib/entry.js b/lib/entry.js new file mode 100644 index 0000000..4d70c64 --- /dev/null +++ b/lib/entry.js @@ -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'); diff --git a/lib/loader.js b/lib/loader.js new file mode 100644 index 0000000..09005ad --- /dev/null +++ b/lib/loader.js @@ -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 diff --git a/package.json b/package.json new file mode 100644 index 0000000..601a79e --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/src/class/AVItemObject.js b/src/class/AVItemObject.js new file mode 100644 index 0000000..582dbb3 --- /dev/null +++ b/src/class/AVItemObject.js @@ -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; diff --git a/src/class/AVLayerObject.js b/src/class/AVLayerObject.js new file mode 100644 index 0000000..650e811 --- /dev/null +++ b/src/class/AVLayerObject.js @@ -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; diff --git a/src/class/BaseObject.js b/src/class/BaseObject.js new file mode 100644 index 0000000..6f94eb9 --- /dev/null +++ b/src/class/BaseObject.js @@ -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; diff --git a/src/class/CameraLayerObject.js b/src/class/CameraLayerObject.js new file mode 100644 index 0000000..a2b0fe5 --- /dev/null +++ b/src/class/CameraLayerObject.js @@ -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; diff --git a/src/class/CollectionObject.js b/src/class/CollectionObject.js new file mode 100644 index 0000000..ab8d28c --- /dev/null +++ b/src/class/CollectionObject.js @@ -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; diff --git a/src/class/CompItemObject.js b/src/class/CompItemObject.js new file mode 100644 index 0000000..9d700d7 --- /dev/null +++ b/src/class/CompItemObject.js @@ -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; diff --git a/src/class/FolderItemObject.js b/src/class/FolderItemObject.js new file mode 100644 index 0000000..81fcbdd --- /dev/null +++ b/src/class/FolderItemObject.js @@ -0,0 +1,19 @@ +'use strict'; + +class FolderItemObject extends C2J.ItemObject { + constructor(obj) { + super(obj); + + // native props + this.items = obj.items; + this.numItems = obj.numItems; + + // native methods + this.item = obj.item; + + } + + // methods +} + +C2J.FolderItemObject = FolderItemObject; diff --git a/src/class/FootageItemObject.js b/src/class/FootageItemObject.js new file mode 100644 index 0000000..d5f13d0 --- /dev/null +++ b/src/class/FootageItemObject.js @@ -0,0 +1,22 @@ +'use strict'; + +class FootageItemObject extends C2J.AVItemObject{ + constructor(obj) { + super(obj); + // native props + if(obj.file) this.file = obj.file; + this.mainSource = C2J.getObject(obj.mainSource); + + // native methods + // this.replace = obj.replace; + // this.replaceWithSequence = obj.replaceWithSequence; + // this.replaceWithPlaceholder = obj.replaceWithPlaceholder; + // this.replaceWithSolid = obj.replaceWithSolid; + // this.openInViewer = obj.openInViewer; + + } + + // methods +} + +C2J.FootageItemObject = FootageItemObject; diff --git a/src/class/FootageSourceObject.js b/src/class/FootageSourceObject.js new file mode 100644 index 0000000..71987dd --- /dev/null +++ b/src/class/FootageSourceObject.js @@ -0,0 +1,29 @@ +'use strict'; + +class FootageSourceObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + + // native props + this.hasAlpha = obj.hasAlpha; + this.alphaMode = obj.alphaMode; + // this.premulColor = obj.premulColor; + // this.invertAlpha = obj.invertAlpha; + this.isStill = obj.isStill; + // this.fieldSeparationType = obj.fieldSeparationType; + // this.highQualityFieldSeparation = obj.highQualityFieldSeparation; + // this.removePulldown = obj.removePulldown; + // this.loop = obj.loop; + // this.nativeFrameRate = obj.nativeFrameRate; + // this.displayFrameRate = obj.displayFrameRate; + // this.conformFrameRate = obj.conformFrameRate; + + // native methods + this.guessAlphaMode = obj.guessAlphaMode; + this.guessPulldown = obj.guessPulldown; + } + + // methods +} + +C2J.FootageSourceObject = FootageSourceObject; diff --git a/src/class/ItemCollectionObject.js b/src/class/ItemCollectionObject.js new file mode 100644 index 0000000..93c17bf --- /dev/null +++ b/src/class/ItemCollectionObject.js @@ -0,0 +1,20 @@ +'use strict'; + +class ItemCollectionObject extends C2J.CollectionObject { + constructor(obj) { + super(obj); + + // native props + this.addFolder = function(name){ + return C2J.getObject(obj.addFolder(name)); + }; + this.addComp = function(option){ + return C2J.getObject(obj.addComp(name)); + }; + + } + + // methods +} + +C2J.ItemCollectionObject = ItemCollectionObject; diff --git a/src/class/ItemObject.js b/src/class/ItemObject.js new file mode 100644 index 0000000..d6cd827 --- /dev/null +++ b/src/class/ItemObject.js @@ -0,0 +1,24 @@ +'use strict'; + +class ItemObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + + // native props + this.name = obj.name; + if(!_.isEmpty(obj.comment)) this.comment = obj.comment; + this.id = obj.id; + // this.parentFolder = obj.parentFolder; + // this.selected = obj.selected; + // this.typeName = obj.typeName; + // this.label = obj.label; + + // native methods + // this.remove = obj.remove; + + } + + // methods +} + +C2J.ItemObject = ItemObject; diff --git a/src/class/LayerCollectionObject.js b/src/class/LayerCollectionObject.js new file mode 100644 index 0000000..068e685 --- /dev/null +++ b/src/class/LayerCollectionObject.js @@ -0,0 +1,23 @@ +'use strict'; + +class LayerCollectionObject extends C2J.CollectionObject { + constructor(obj) { + super(obj); + + // native methods + // this.add = obj.add; + // this.addNull = obj.addNull; + // this.addSolid = obj.addSolid; + // this.addText = obj.addText; + // this.addBoxText = obj.addBoxText; + // this.addCamera = obj.addCamera; + // this.addLight = obj.addLight; + // this.addShape = obj.addShape; + // this.byName = obj.byName; + // this.precompose = obj.precompose; + } + + // methods +} + +C2J.LayerCollectionObject = LayerCollectionObject; diff --git a/src/class/LayerObject.js b/src/class/LayerObject.js new file mode 100644 index 0000000..cc0ea02 --- /dev/null +++ b/src/class/LayerObject.js @@ -0,0 +1,45 @@ +'use strict'; + +class LayerObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + + // native props + this.index = obj.index; + this.name = obj.name; + if(!_.isEmpty(obj.parent)) this.parent = obj.parent.index; + // this.time = obj.time; + if(!_.isEmpty(obj.startTime)) this.startTime = obj.startTime; + if(obj.stretch !== 100) this.stretch = obj.stretch; + if(!_.isEmpty(obj.inPoint)) this.inPoint = obj.inPoint; + if(!_.isEmpty(obj.outPoint)) this.outPoint = obj.outPoint; + // this.enabled = obj.enabled; + if(obj.solo) this.solo = obj.solo; + if(obj.shy) this.shy = obj.shy; + // this.locked = obj.locked; + // this.hasVideo = obj.hasVideo; + // this.active = obj.active; + if(obj.nullLayer) this.nullLayer = obj.nullLayer; + // this.selectedProperties = obj.selectedProperties; + if(!_.isEmpty(obj.comment)) this.comment = obj.comment; + // this.containingComp = obj.containingComp; + // this.isNameSet = obj.isNameSet; + + // native methods + // this.remove = obj.remove; + // this.moveToBeginning = obj.moveToBeginning; + // this.moveToEnd = obj.moveToEnd; + // this.moveAfter = obj.moveAfter; + // this.moveBefore = obj.moveBefore; + // this.duplicate = obj.duplicate; + // this.copyToComp = obj.copyToComp; + // this.activeAtTime = obj.activeAtTime; + // this.setParentWithJump = obj.setParentWithJump; + // this.applyPreset = obj.applyPreset; + + } + + // methods +} + +C2J.LayerObject = LayerObject; diff --git a/src/class/LightLayerObject.js b/src/class/LightLayerObject.js new file mode 100644 index 0000000..875fec6 --- /dev/null +++ b/src/class/LightLayerObject.js @@ -0,0 +1,20 @@ +'use strict'; + +class LightLayerObject extends C2J.AVLayerObject { + constructor(obj) { + super(obj); + + // native props + this.type = 'LightLayerObject'; + if(obj.lightType) this.lightType = obj.lightType; + + // PropertyObjects + var lightOptions = C2J.getObject(obj("ADBE Light Options Group")); + if(obj("ADBE Light Options Group").isModified) this.lightOptions = lightOptions; + + } + + // methods +} + +C2J.LightLayerObject = LightLayerObject; diff --git a/src/class/MarkerValueObject.js b/src/class/MarkerValueObject.js new file mode 100644 index 0000000..61cf5d9 --- /dev/null +++ b/src/class/MarkerValueObject.js @@ -0,0 +1,16 @@ +'use strict'; + +class MarkerValueObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + if(!_.isEmpty(obj.comment)) this.comment = obj.comment; + if(!_.isEmpty(obj.duration)) this.duration = obj.duration; + if(!_.isEmpty(obj.chapter)) this.chapter = obj.chapter; + if(!_.isEmpty(obj.cuePointName)) this.cuePointName = obj.cuePointName; + if(!_.isEmpty(obj.eventCuePoint)) this.eventCuePoint = obj.eventCuePoint; + if(!_.isEmpty(obj.url)) this.url = obj.url; + if(!_.isEmpty(obj.frameTarget)) this.frameTarget = obj.frameTarget; + } +} + +C2J.MarkerValueObject = MarkerValueObject; diff --git a/src/class/MaskPropertyGroupObject.js b/src/class/MaskPropertyGroupObject.js new file mode 100644 index 0000000..ce1e83c --- /dev/null +++ b/src/class/MaskPropertyGroupObject.js @@ -0,0 +1,18 @@ +'use strict'; + +class MaskPropertyGroupObject extends C2J.PropertyGroupObject { + constructor(obj) { + super(obj); + + // native props + this.maskMode = obj.maskMode; + if(obj.inverted) this.inverted = obj.inverted; + if(obj.rotoBezier) this.rotoBezier = obj.rotoBezier; + if(obj.maskMotionBlur) this.maskMotionBlur = obj.maskMotionBlur; + if(obj.locked) this.locked = obj.locked; + this.color = obj.color; + this.maskFeatherFalloff = obj.maskFeatherFalloff; + } +} + +C2J.MaskPropertyGroupObject = MaskPropertyGroupObject; diff --git a/src/class/PropertyBaseObject.js b/src/class/PropertyBaseObject.js new file mode 100644 index 0000000..7c631e1 --- /dev/null +++ b/src/class/PropertyBaseObject.js @@ -0,0 +1,33 @@ +'use strict'; + +class PropertyBaseObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + + // native props + this.name = obj.name; + // this.matchName = obj.matchName; + // this.propertyIndex = obj.propertyIndex; + // this.propertyDepth = obj.propertyDepth; + // this.propertyType = obj.propertyType; + // this.parentProperty = obj.parentProperty; + // this.isModified = obj.isModified; + // this.canSetEnabled = obj.canSetEnabled; + // this.enabled = obj.enabled; + // this.active = obj.active; + // this.elided = obj.elided; + // this.isEffect = obj.isEffect; + // this.isMask = obj.isMask; + // this.selected = obj.selected; + + // native methods + // this.propertyGroup = obj.propertyGroup; + // this.remove = obj.remove; + // this.moveTo = obj.moveTo; + // this.duplicate = obj.duplicate; + } + + // methods +} + +C2J.PropertyBaseObject = PropertyBaseObject; diff --git a/src/class/PropertyGroupObject.js b/src/class/PropertyGroupObject.js new file mode 100644 index 0000000..f0132e7 --- /dev/null +++ b/src/class/PropertyGroupObject.js @@ -0,0 +1,29 @@ +'use strict'; + +class PropertyGroupObject extends C2J.PropertyBaseObject { + constructor(obj) { + super(obj); + + // native props + this.numProperties = obj.numProperties; + + // native methods + // this.property = obj.property; + // this.canAddProperty = obj.canAddProperty; + // this.addProperty = obj.addProperty; + + this.properties = {}; + for (var i = 1; i <= this.numProperties; i++) { + var o = obj(i); + if(!o.isModified) continue; + if(o.matchName === 'ADBE Position_0' && o.value === 0) continue; + if(o.matchName === 'ADBE Position_1' && o.value === 0) continue; + if(o.matchName === 'ADBE Position_2' && o.value === 0) continue; + var name = o.matchName; + this.properties[name] = C2J.getObject(o); + } + return this.properties; + } +} + +C2J.PropertyGroupObject = PropertyGroupObject; diff --git a/src/class/PropertyObject.js b/src/class/PropertyObject.js new file mode 100644 index 0000000..55dd0ef --- /dev/null +++ b/src/class/PropertyObject.js @@ -0,0 +1,94 @@ +'use strict'; + +class PropertyObject extends C2J.PropertyBaseObject { + constructor(obj) { + super(obj); + + // native props + // this.propertyValueType = obj.propertyValueType; + var value = C2J.getPropertyValue(obj); + if(!_.isNull(value)) this.value = value; + // this.hasMin = obj.hasMin; + // this.hasMax = obj.hasMax; + // this.minValue = this.hasMin ? obj.minValue : null; + // this.maxValue = this.hasMax ? obj.maxValue : null; + // this.isSpatial = obj.isSpatial; + // this.canVaryOverTime = obj.canVaryOverTime; + // this.isTimeVarying = obj.isTimeVarying; + // if (obj.numKeys > 0) this.numKeys = obj.numKeys; + // this.unitsText = obj.unitsText; + if (obj.expression) this.expression = obj.expression; + // this.canSetExpression = obj.canSetExpression; + if (obj.expressionEnabled) this.expressionEnabled = obj.expressionEnabled; + // this.expressionError = obj.expressionError; + // this.selectedKeys = obj.selectedKeys; + // this.propertyIndex = obj.propertyIndex; + // this.dimensionsSeparated = obj.dimensionsSeparated; + // this.isSeparationFollower = obj.isSeparationFollower; + // this.isSeparationLeader = obj.isSeparationLeader; + // this.separationDimension = this.isSeparationFollower ? obj.separationDimension : null; + // this.separationLeader = this.isSeparationLeader ? obj.separationLeader : null; + + // native methods + // this.valueAtTime = obj.valueAtTime; + // this.setValue = obj.setValue; + // this.setValueAtTime = obj.setValueAtTime; + // this.setValuesAtTimes = obj.setValuesAtTimes; + // this.setValueAtKey = obj.setValueAtKey; + // this.nearestKeyIndex = obj.nearestKeyIndex; + // this.keyTime = obj.keyTime; + // this.keyValue = obj.keyValue; + // this.addKey = obj.addKey; + // this.removeKey = obj.removeKey; + // this.isInterpolationTypeValid = obj.isInterpolationTypeValid; + // this.setInterpolationTypeAtKey = obj.setInterpolationTypeAtKey; + // this.keyInInterpolationType = obj.keyInInterpolationType; + // this.keyOutInterpolationType = obj.keyOutInterpolationType; + // this.setSpatialTangentsAtKey = obj.setSpatialTangentsAtKey; + // this.keyInSpatialTangent = obj.keyInSpatialTangent; + // this.keyOutSpatialTangent = obj.keyOutSpatialTangent; + // this.setTemporalEaseAtKey = obj.setTemporalEaseAtKey; + // this.keyInTemporalEase = obj.keyInTemporalEase; + // this.keyOutTemporalEase = obj.keyOutTemporalEase; + // this.setTemporalContinuousAtKey = obj.setTemporalContinuousAtKey; + // this.keyTemporalContinuous = obj.keyTemporalContinuous; + // this.setTemporalAutoBezierAtKey = obj.setTemporalAutoBezierAtKey; + // this.keyTemporalAutoBezier = obj.keyTemporalAutoBezier; + // this.setSpatialContinuousAtKey = obj.setSpatialContinuousAtKey; + // this.keySpatialContinuous = obj.keySpatialContinuous; + // this.setSpatialAutoBezierAtKey = obj.setSpatialAutoBezierAtKey; + // this.keySpatialAutoBezier = obj.keySpatialAutoBezier; + // this.setRovingAtKey = obj.setRovingAtKey; + // this.keyRoving = obj.keyRoving; + // this.setSelectedAtKey = obj.setSelectedAtKey; + // this.keySelected = obj.keySelected; + // this.getSeparationFollower = obj.getSeparationFollower; + + // get keyframes + if(obj.numKeys > 0){ + delete this.value; + this.keys = []; + for (var i = 1; i <= obj.numKeys; i++) { + var key = { + time: obj.keyTime(i), + value: C2J.getPropertyValue(obj.keyValue(i)) + }; + // マーカー + if(C2J.getType(obj.keyValue(i)) !== 'Object'){ + // キーフレームだけ + if(obj.propertyValueType === PropertyValueType.ThreeD_SPATIAL || obj.propertyValueType === PropertyValueType.TwoD_SPATIAL){ + key.in = obj.keyInSpatialTangent(i); + key.out = obj.keyOutSpatialTangent(i); + }else{ + key.in = obj.keyInTemporalEase(i); + key.out = obj.keyOutTemporalEase(i); + } + } + this.keys.push(key); + } + } + } + +} + +C2J.PropertyObject = PropertyObject; diff --git a/src/class/ShapeLayerObject.js b/src/class/ShapeLayerObject.js new file mode 100644 index 0000000..b67a4e3 --- /dev/null +++ b/src/class/ShapeLayerObject.js @@ -0,0 +1,18 @@ +'use strict'; + +class ShapeLayerObject extends C2J.AVLayerObject { + constructor(obj) { + super(obj); + + this.type = 'ShapeLayerObject'; + + // PropertyObjects + var contents = C2J.getObject(obj("ADBE Root Vectors Group")); + if(obj("ADBE Root Vectors Group").isModified) this.contents = contents; + + } + + // methods +} + +C2J.ShapeLayerObject = ShapeLayerObject; diff --git a/src/class/ShapeObject.js b/src/class/ShapeObject.js new file mode 100644 index 0000000..8c17286 --- /dev/null +++ b/src/class/ShapeObject.js @@ -0,0 +1,22 @@ +'use strict'; + +class ShapeObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + + // native props + this.closed = obj.closed; + this.vertices = obj.vertices; + this.inTangents = obj.inTangents; + this.outTangents = obj.outTangents; + if(!_.isEmpty(obj.featherSegLocs)) this.featherSegLocs = obj.featherSegLocs; + if(!_.isEmpty(obj.featherRelSegLocs)) this.featherRelSegLocs = obj.featherRelSegLocs; + if(!_.isEmpty(obj.featherRadii)) this.featherRadii = obj.featherRadii; + if(!_.isEmpty(obj.featherInterps)) this.featherInterps = obj.featherInterps; + if(!_.isEmpty(obj.featherTensions)) this.featherTensions = obj.featherTensions; + if(!_.isEmpty(obj.featherTypes)) this.featherTypes = obj.featherTypes; + if(!_.isEmpty(obj.featherRelCornerAngles)) this.featherRelCornerAngles = obj.featherRelCornerAngles; + } +} + +C2J.ShapeObject = ShapeObject; diff --git a/src/class/SolidSourceObject.js b/src/class/SolidSourceObject.js new file mode 100644 index 0000000..831bdec --- /dev/null +++ b/src/class/SolidSourceObject.js @@ -0,0 +1,15 @@ +'use strict'; + +class SolidSourceObject extends C2J.FootageSourceObject { + constructor(obj) { + super(obj); + + // native props + this.type = 'SolidSourceObject'; + this.color = obj.color; + + } + +} + +C2J.SolidSourceObject = SolidSourceObject; diff --git a/src/class/TextDocumentObject.js b/src/class/TextDocumentObject.js new file mode 100644 index 0000000..23c09a2 --- /dev/null +++ b/src/class/TextDocumentObject.js @@ -0,0 +1,51 @@ +'use strict'; + +class TextDocumentObject extends C2J.BaseObject { + constructor(obj) { + super(obj); + + // native props + this.text = obj.text; + this.font = obj.font; + this.fontFamily = obj.fontFamily; + // this.fontLocation = obj.fontLocation; + if(obj.fontStyle !== 'Regular') this.fontStyle = obj.fontStyle; + this.fontSize = obj.fontSize; + if(!obj.applyFill) this.applyFill = obj.applyFill; + if(!obj.applyStroke) this.applyStroke = obj.applyStroke; + if(obj.applyFill) this.fillColor = obj.fillColor; + if(obj.applyStroke) this.strokeColor = obj.strokeColor; + if(obj.applyStroke) this.strokeOverFill = obj.strokeOverFill; + if(obj.applyStroke) this.strokeWidth = obj.strokeWidth; + if(obj.justification !== ParagraphJustification.LEFT_JUSTIFY) this.justification = obj.justification; + if(obj.tracking !== 0) this.tracking = obj.tracking; + if(obj.pointText) this.pointText = obj.pointText; + if(obj.boxText) this.boxText = obj.boxText; + if(obj.boxText) this.boxTextSize = obj.boxTextSize; + if(obj.baselineLocs) this.baselineLocs = obj.baselineLocs; + if(obj.fauxBold) this.fauxBold = obj.fauxBold; + if(obj.fauxItalic) this.fauxItalic = obj.fauxItalic; + if(obj.allCaps) this.allCaps = obj.allCaps; + if(obj.smallCaps) this.smallCaps = obj.smallCaps; + if(obj.superscript) this.superscript = obj.superscript; + if(obj.subscript) this.subscript = obj.subscript; + if(obj.verticalScale !==1) this.verticalScale = obj.verticalScale; + if(obj.horizontalScale !==1) this.horizontalScale = obj.horizontalScale; + if(obj.baselineShift !== 0) this.baselineShift = obj.baselineShift; + if(obj.tsume !== 0) this.tsume = obj.tsume; + if(obj.boxText) this.boxTextPos = obj.boxTextPos; + + // native methods + // this.resetCharStyle = obj.resetCharStyle; + // this.resetParagraphStyle = obj.resetParagraphStyle; + // this.sourcePointToComp = obj.sourcePointToComp; + // this.compPointToSource = obj.compPointToSource; + + // this.remove = obj.remove; + + } + + // methods +} + +C2J.TextDocumentObject = TextDocumentObject; diff --git a/src/class/TextLayerObject.js b/src/class/TextLayerObject.js new file mode 100644 index 0000000..a27fea7 --- /dev/null +++ b/src/class/TextLayerObject.js @@ -0,0 +1,18 @@ +'use strict'; + +class TextLayerObject extends C2J.AVLayerObject { + constructor(obj) { + super(obj); + + this.type = 'TextLayerObject'; + + // PropertyObjects + var text = C2J.getObject(obj("ADBE Text Properties")); + if(obj("ADBE Text Properties").isModified) this.text = text; + + } + + // methods +} + +C2J.TextLayerObject = TextLayerObject; diff --git a/src/class/Util.js b/src/class/Util.js new file mode 100644 index 0000000..3179a7c --- /dev/null +++ b/src/class/Util.js @@ -0,0 +1,39 @@ +'use strict'; + +const util = { + json: function(anything){ + if(anything === null || anything === 'undifiend') return null; + return JSON.stringify(anything, null, ' '); + }, + getType: function(anything){ + if(anything === null || anything === 'undifiend') return null; + var objstr = String(anything); + if(objstr.match(/\[object (.*)\]/)){ + return objstr.match(/\[object (.*)\]/)[1]; + } + return objstr; + }, + getObject: function(anything){ + if(anything === null || anything === 'undifiend') return null; + var type = C2J.getType(anything); + if(C2J[`${type}Object`]){ + return new C2J[`${type}Object`](anything); + } + return null; + }, + getPropertyValue: function(obj){ + switch (obj.propertyValueType) { + case PropertyValueType.TEXT_DOCUMENT: + return new C2J.TextDocumentObject(obj.value); + case PropertyValueType.SHAPE: + return new C2J.ShapeObject(obj.value); + case PropertyValueType.NO_VALUE: + return null; + default: + return obj.value; + } + } +}; + +// C2Jに含める +_.extend(C2J, util); diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..b3cafad --- /dev/null +++ b/src/main.js @@ -0,0 +1,12 @@ +'use strict'; +var file = File.saveDialog("保存するファイル名を入れてください"); +if(file){ + var activeitem = app.project.activeItem; + var l = C2J.getObject(activeitem); + file.open("w"); + file.encoding = "UTF-8"; + file.lineFeed = "Unix"; + file.write(C2J.json(l)); + file.close(); + alert(`jsonを出力しました。`); +} diff --git a/src/sample.json b/src/sample.json new file mode 100644 index 0000000..b0a3bc1 --- /dev/null +++ b/src/sample.json @@ -0,0 +1,110 @@ +{ + "name": "aaaaa", + "id": 1, + "width": 1920, + "height": 1080, + "frameRate": 29.9700012207031, + "frameDuration": 0.03336670003337, + "duration": 10800, + "dropFrame": true, + "motionBlur": true, + "draft3d": true, + "displayStartTime": 0, + "renderer": "ADBE Advanced 3d", + "layers": [{ + "index": 1, + "name": "aaaaa", + "type": "TextLayerObject", + "source": null, + "isNameFromSource": false, + "height": 1080, + "width": 1920, + "collapseTransformation": null, + "transform": { + "ADBE Position": { + "name": "位置", + "value": [957.478454589844, 585.155457608402, 0] + } + }, + "text": { + "ADBE Text Document": { + "name": "ソーステキスト", + "value": { + "text": "aaaaa", + "font": "TsukuARdGothic-Regular", + "fontFamily": "Tsukushi A Round Gothic", + "fontSize": 188, + "fillColor": [1, 1, 1], + "strokeColor": [1, 1, 1], + "strokeOverFill": true, + "strokeWidth": 0.00999999977648, + "justification": 7015, + "pointText": true + } + } + } + }, { + "index": 2, + "name": "カメラ 1", + "type": "CameraLayerObject", + "source": null, + "autoOrient": 3814, + "transform": { + "ADBE Anchor Point": { + "name": "目標点", + "value": [977, 254, 149] + }, + "ADBE Position": { + "name": "位置", + "value": [1150, 540, -833.33333331] + }, + "ADBE Orientation": { + "name": "方向", + "value": [0, 174, 0] + }, + "ADBE Rotate Y": { + "name": "Y 回転", + "value": 75 + }, + "ADBE Rotate Z": { + "name": "Z 回転", + "value": 505 + } + }, + "cameraOptions": { + "ADBE Camera Zoom": { + "name": "ズーム", + "value": 833.33333331 + }, + "ADBE Camera Focus Distance": { + "name": "フォーカス距離", + "value": 833.33333331 + }, + "ADBE Camera Aperture": { + "name": "絞り", + "value": 25.3093363329584 + } + } + }, { + "index": 3, + "name": "fee", + "type": "AVLayerObject", + "source": { + "name": "fee", + "id": 13, + "width": 1920, + "height": 1080, + "frameRate": 0, + "duration": 0, + "mainSource": { + "hasAlpha": false, + "alphaMode": 5012, + "isStill": true, + "type": "SolidSourceObject", + "color": [0, 0, 0] + } + }, + "height": 1080, + "width": 1920 + }] +}