How to upload video into product detail page on PrestaShop (Without additional module)

Video file(s) type that you have to prepare is,
1. .mp4 (For Internet Explorer 9+, Chrome 6+, Safari 5+, and Safari Mobile as well)
2. .ogv (For Chrome 6+, Firefox 3.6+, Opera 10.6+)

Then follow these steps,
1. Login to your PrestaShop Back Office
2. To go your product that you want to upload video.
3. Find Description box.
4. Click on Video icon

Video Icon

Video Icon (The green color one).

5. Then select “media_dig.video

Media Type

6. Click on Advanced then select video file on Alternation source 1 and Alternative source 2

Embadded Media Advanced

Video Selecting

7. After selected videos for Alternative source 1 and Alternative source 2 with .mp4 and .ogv. Then Click on Controls option.

Controls Option

8. Click Insert

9. Done. Now the Video is in your Short description/Description box already.

Enjoy Video!

CSS Coding Standards [Thai language]

เราเขียนโค้ดตามรูปแบบตามมาตรฐานไปทำไม? Coder มือใหม่หลายๆคนอาจจะยังไม่รู้หรือบางคนทำงานหรือเรียนมานานแล้วก็ไม่ได้ใส่ใจก็มี (ลองดูสิจะเห็นความแตกต่างมากครับ ไม่เฉพาะกับ CSS นะครับ การเขียนโปรแกรมทุกภาษาเลย) การเขียนให้เป็นมาตรฐานนี้มันจะช่วยให้โค้ดของเรานั้นสามารถจัดการได้ง่ายขึ้น ดูเป็นระบบระเบียบมากขึ้น แล้วยิ่งในกรณีที่มีคนอื่นทำงานร่วมกับเราด้วย จะได้ลดปัญหาที่อาจจะเกิดขึ้นได้ จากการอ่านโค้ด เพราะโค้ดที่เราเขียนขึ้นมานั้นหากเขียนถูกต้องตามมาตรฐานแล้วมันจะทำให้อ่านได้ง่ายขึ้น และนั่นก็จะช่วยให้ debugging ได้ง่ายขึ้นอีกด้วย

Block Style

selector {
    property: value;
}
  • แต่ละ selector ควรแบ่งเป็นบรรทัดของตัวเอง ถ้าต้องการประกาศหลายๆ selector ต่อกัน ควรใช้เครื่องหมาย comma (,) ปิด selector แล้วตัวต่อมาก็ขึ้นบรรทัดใหม่
  • Property-value ก็ควรแบ่งเป็นบรรทัดเหมือนกัน และควรใช้ indent มา 1 tab และปิดด้วยเครื่องหมาย semicolon (;)
  • การใช้เครื่องหมายปีกกาปิด (}) ควรไว้ชิดซ้ายสุด ตรงกับตำแหน่งที่เราเปิด selector เอาไว้
  • แต่ส่วนแต่ละส่วนโดยการเว้นบรรทัดว่างไว้ 2 บรรทัด แต่ภายใน block เดียวกัน ไม่ควรเว้นว่างไว้

แบบที่ถูกต้อง:

#selector-1,
#selector-2,
#selector-3 {
    background: #fff;
    color: #000;
}

แบบที่ไม่ถูกต้อง:

#selector-1, #selector-2, #selector-3 {
    background: #fff; color: #000;
    }

แบบนี้ก็ไม่ถูกต้อง:

#selector-1 { background: #fff; color: #000; }

Selectors

  • การตั้งชื่อตัว selector ควรใช้ตัวอักษรตัวพิมพ์เล็ก (lowercase) และใช้เครื่องหมายยัตภังค์ (hyphen หรือเครื่องหมาย -) แทนการใช้ตัวพิมพ์ใหญ่มาเชื่อมต่อคำหรือใช้ตัวขีดเส้นใต้ (underscore หรือ _)
  • ใช้ภาษาที่มนุษย์อ่านออก ตั้งชื่อให้สื่อความหมายว่า selector ตัวนี้คืออะไร

แบบที่ถูกต้อง:

#comment-form {
    margin: 0;
}

แบบที่ไม่ถูกต้อง:

#commentForm { /* Avoid camelcase. */
    margin: 0;
}
#comment_form { /* Avoid underscores. */
    margin: 0;
}
#c1-xr { /* What is a c1-xr?! Use a better name. */
    margin: 0;
}

Properties and Values

  • Properties ควรเรียงตามลำดับตัวอักษร ยกเว้นในบางกรณี เช่น หากประกาศ width และ height ทั้งคู่ 2 properties นี้ควรอยู่ด้วยกัน
  • Properties ควรตามด้วยเครื่องหมาย Colon (:) และเว้นวรรค 1 วรรค ก่อนระบุค่า
  • ทุก properties และ values ควรเป็นตัวอักษรพิมพ์เล็ก (lowercase) ยกเว้นชื่อฟอนต์หรือ properties เฉพาะบางตัว
  • ใช้ hex code สำหรับการใส่สี และพยายามไม่ใช้รูปแบบ RGB และตัวพิมพ์ใหญ่ (uppercase) และใช้ค่าที่สั้นที่สุดถ้าเป็นไปได้ เช่น ในกรณีให้ค่าสีขาว ควรให้เป็น #fff แทน #FFFFFF
  • ใช้รูปแบบ shorthand (ยกเว้นในบางกรณี) สำหรับค่าใน background, border, font, list-style, margin และ padding (แล้ว shorthand คืออะไร? เดี้ยวจะมีตัวอย่างในท้ายหัวข้อนี้ครับ)

การใช้ prefixed ของแต่ละ vendor ก่อน

#selector-1 {
    -moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);
    -webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);
    box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);
    display: none;
    float: left;
}

ในกรณี properties ของ position (top, right, bottom, left) ควรจัดเป็นกลุ่มโดยนอกเหนือกฏของการเรียงลำดับตัวอักษรไป และใช้ tab ในการ indent เข้าไปอีก 1 ที

#selector-1 {
    font-size: 1em;
    position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    width: 100px;
    z-index: 1;
}

ถ้าหาก width และ height ถูกประกาศมาด้วยกัน ก็ให้เขาทั้งคู่มาต่อกันเลย โดย height ควรอยู่ติดใต้ weight

#selector-1 {
    width: auto;
    height: auto;
}

ส่วน shorthand คืออะไร?
เช่น ในกรณีที่เราเขียน margin เราไม่จำเป็นต้องเขียนแบบนี้เลย เนื่องจาก margin ค่าจะไล่ตามทิศทางการหมุนของนาฬิกาอยู่แล้ว (clock-wise positions)

.box {
    margin-top: 10px;
    margin-right: 20px; 
    margin-bottom: 10px;
    margin-left: 20px;
}

ซึ่งเราสามารถเขียนแบบนี้ได้เลย ซึ่งทำให้โค้ดเราสั้นลงด้วย

.box {
    margin: 10px 20px 10px 20px;
}

รวมถึงหากเราจะให้ค่า top และ bottom มีค่าเท่ากันคือ 10px และ left และ right มีค่าเท่ากันคือ 20px เราก็สามารถเขียนแบบนี้ได้เลย

.box {
    margin: 10px 20px;
}

หรือในกรณีที่เหมือนด้านบน แต่ไม่ต้องการให้ bottom มีค่าอะไร ก็สามารถทำแบบนี้ได้เลย

.box {
    margin: 10px 20px 0;
}

ลองดูตัวอย่างของการเขียน border นะครับ

.box {
    border-top: 1px;
    border-right: 1px;
    border-bottom: 1px; 
    border-left: 1px;
    border-color: blue;
    border-style: solid}

เราก็สามารถรวมทั้งหมดมาเขียนแบบนี้ได้เลย

.box {
    border: 1px blue solid;
}

Comments

/* Short comments: one line with no trailing space. */
#selector-1 {...

#selector-1 {
    color: #000; /* A short comment can also follow one property/value pair. */
}

/*
For longer, multiple line comments that need more room,
add a newline before and after the comment.
Leave one line of space before the next block.
*/

#selector-1 {...

สำหรับการขึ้นหัวข้อใหม่ (section) ก็ควรเว้นบรรทัด 2 บรรทัดจากส่วนอื่นครับ

#previous-block {
    color: #000;
}


/* =Name of section
-------------------------------------------------------------- */

#selector-1 {...

หวังว่าคงเป็นประโยชน์ไม่มากก็น้อยนะครับ
ขอให้มีความสุขกับการเขียน CSS ครับ : )

รวบรวมและแปลจาก WordPress’s Codex : CSS Coding Standards และ CSS Shorthand

[How to] Level Of Detail (LOD) – X3D(OM) Language [Tutorial in Thai language]

Level Of Detail (LOD) นั้นเป็น Grouping node ตัวหนึ่งในภาษา X3D (หรือเอามาใช้กับ X3DOM ก็ได้ซึ่งใช้ภาษาในการเขียนเป็น X3D เหมือนกัน)
โดย node นี้จะถูกใช้เพื่อการเพิ่มประสิทธิภาพในการเรนเดอร์วัตถุใน Scene เนื่องจากใน Scene ของเรานั้นจะมี Viewpoint อยู่อย่างน้อย node ซึ่งจะเป็นจุดกล้องของเรานั่นเอง ซึ่งมีความห่างในแกน x, y, z กับวัตถุ ซึ่งระยะห่างนี้เราสามารถกำหนดความละเอียดให้กับวัตถุที่เรามองเห็นได้ ลองนึกภาพว่าคุณมองวัตถุที่เห็นไกลๆแล้วคุณเห็นมันไม่ชัด คุณเดินเข้าไปใกล้ขึ้นเรื่อยๆ วัตถุนั้นก็จะชัดขึ้นเรื่อยๆตามลำดับ หากใครที่เคยเล่นเกมแนว 3D มาคงจะพอนึกภาพออกว่าเป็นยังไง
และความละเอียดนั่นเองที่เราจะถูกถึงการเพิ่มประสิทธิภาพของการเรนเดอร์ทั้ง Scene นั้นโดยรวม โดยเฉพาะอย่างยิ่งกับ Scene ที่มีวัตถุหลายๆวัตถุ เราก็ควรจะให้ความสำคัญกับวัตถุที่เราอยู่ใกล้ที่สุด คือ ให้เรามองเห็นสิ่งนั้นชัดที่สุด ละเอียดที่สุด นั่นหมายความว่า ยิ่งความละเอียดเยอะ ยิ่งมี Polygon มาก มีจุดมากนั่นเอง ซึ่งจำนวนจุด (Point) จำนวนรูปสามเหลี่ยม (Triangle) นั่นส่งผลต่อประสิทธิภาพในการเรนเดอร์และค่า Frame rate (หากดู Monitor ของ X3DOM คุณจะเห็นค่านี้แสดงเป็น x FPS โดย x เป็นตัวเลข Floating Point) หรือจากระยะหนึ่ง เข้าไปแล้วให้วัตถุเปลี่ยนไป เข้าไปอีกก็เปลี่ยนไปอีก ก็ได้แล้วแต่เราจะทำครับ

หลังจากพอเข้าใจหลักการคร่าวๆว่าโหนดนี้มีประโยชน์อย่างไร เรามาถึงวิธีการเขียนโหนด LOD กันครับ

<LOD center="0 0 0" range="10 15 20">

	<Group>
		<Shape DEF="Box">
			<Appearance DEF="BlueColor">
				<Material diffuseColor="0.0 0.2 0.8" />
			</Appearance>
			<Box />
		</Shape>
	</Group>

	<Group>
		<Shape>
			<Appearance USE="BlueColor"></Appearance>
			<Cone />
		</Shape>
	</Group>

	<Group>
		<Shape>
			<Appearance USE="BlueColor"></Appearance>
			<Cylinder />
		</Shape>
	</Group>
						
	<WorldInfo info='"null node"' />

</LOD>

จาก Source code
1. เริ่มประกาศโหนด LOD โดยกำหนด Attribute ให้ center มีค่าเป็น 0 0 0 นั่นหมายถึงเริ่มนับตำแหน่งของ LOD ที่จุด 0 0 0 คือจุดกลางของโหนดครับ (ทั้งนี้ไม่นับรวมถึงโหนด Transform นี่ครอบโหนด LOD นี้อีกที) และ range คือระยะห่างจากโหนด LOD ครับ จากตัวอย่างผมให้ระยะห่างเป็น 3 ช่วงคือ 10 15 และ 20 ครับ
2. จากนั้นแบ่งกลุ่มของวัตถุครับ ดังจะเห็นในบรรทัดที่ 3, 12 และ 19 นั่นคือการแบ่งช่วงระยะห่าง โดยนับจาก range คือ ระยะห่างจาก LOD ช่วง 0-10 จะแสดงวัตถุในกลุ่มแรก และมากกว่า 10-15 ก็จะแสดงวัตถุในกลุ่มที่สอง ตามด้วยช่วงมากกว่า 15-20 คือแสดงวันถุในกลุ่มที่สาม และหากระยะห่างจากจุด LOD มากกว่า 20 ขึ้นไป จะแสดงค่าตามบรรทัดที่ 26 ครับ คือบรรทัดนั้นผมกำหนดให้เขาเป็น null node นั่นหมายความว่า จะไม่แสดงอะไรเลย LOD นั้นก็จะหลายเป็นค่าว่างเลยครับ จะไม่มีจุดหรือสามเหลี่ยมอะไรที่ถูกเรนเดอร์ใน LOD นั้นแล้วครับ

จากตัวอย่างผมใช้วิธีเขียนวัตถุโดยใช้ Shape ในการเริ่มสร้างวัตถุง่ายๆขึ้นมาเช่น Box หรือ กล่อง, Cone หรือ กรวย และ Cylinder หรือวัตถุทรงกระบอกโดยให้ค่าเริ่มต้นเป็นค่าพื้นฐาน (Default) ตัววัตถุนั้นๆไป หากต้องการลูกเล่นเพิ่มเริม เราสามารถใช้โหนด Inline ในการเรียกวัตถุจากภายนอกไฟล์มาแทนในกลุ่มนั้นก็ได้ครับ โดยแทนโหนด Shape ไปครับ : )

Get navigation type and set point rendering by using X3DOM Runtime API

First you have to call this method: ready() It is therefore possible to execute custom action by overriding this method in your code:

x3dom.runtime.ready = function()
{
	var id = "x3dom-scene";
	var configure = document.getElementById(id);
	
	/* Default view */
	configure.runtime.showAll();
	getNavigationType(id);
	
	/* =============================================================
	 Arguments:	show (boolean) – true/false to show or hide the debug window
	 Returns: The current visibility status of the debug window (true/false)
	 Displays or hides the debug window. If the parameter is omitted, the current visibility status is returned.
	 ============================================================= */
	configure.runtime.debug(false);
	
	/* =============================================================
	 Arguments:	mode (boolean) – true/false to enable or disable the stats info
	 Returns:The current visibility of the stats info (true/false)
	 Get or set the visibility of the statistics information.
	 If parameter is omitted, this method returns the visibility status as boolean.
	 ============================================================= */
	configure.runtime.statistics(false)
}

That’s your X3DOM scene ID is “x3dom-scene” and your default viewpoint is “showAll”

function getNavigationType(id)
{
	var configure = document.getElementById(id);
	
	var navigationTypeName = configure.runtime.navigationType();
	var currentViewpoint = configure.runtime.viewpoint();
	
	console.log(navigationTypeName);
	console.log(currentViewpoint);
	
	document.getElementById('showNavigationType').innerHTML = navigationTypeName;
	setSpeed(0, id);
}

This method is used to show your current navigation type and your current viewpoint in your X3DOM scene and appear the result to your browser console. and Now, I think you should know how to use X3DOM Runtime API method to your X3DOM scene.

So this is the method that doesn’t public on official page of X3DOM Runtime API, togglePoints method. This method is used to change render type from other to point rendering.

function togglePoint()
{
	var configure = document.getElementById("x3dom-scene");
	configure.runtime.togglePoints();
}

The result example:

When this method was called, your geometry will appear like this.

togglePoints Demo

How to get and set walk speed value in VRML

How to get and set walk speed value in VRML (VRML version 2.0).

First, you have to create an object for call the javascript function. such as TouchSensor node.

Then, create ROUTE for call the function.

So if you clicked the box that DEF is setWalkSpeed_UP_TOUCH then it’ll call the script at DEF is setWalkSpeed_UP_SCRIPT.

And this is the main part, the JavaScript function.

For this example code, when you clicked the box it’ll set walk speed to 5 and current walk speed will show you on console.

Done! (=

[Mac OS X] Remove Background from photo via Preview

The easiest way to remove background from photo on a Mac. : )

1. Your Image.

Your Image

2. “Select” -> Choose “Instant Alpha”

"Select" -> Choose "Instant Alpha"

3. Just drag on the place that you want to cut. And then press “delete” button.

Just drag on the place that you want to cut. And then press "delete" button.

4. After That, Save as PNG, PDF, TIFF or GIF file. Don’t forget to check “Alpha”

After That, Save as PNG, PDF, TIFF or GIF file. Don't forget to check "Alpha"

5. Done! : )

Note: This option also can use via Keynote from iWork.

[X3DOM Demo] Create geometry by using JavaScript

1. Prepare your HTML file.
Don’t forget to link your HTML file with x3dom.js and spheretroupe.js or your JS file.

SphereTroupe: Link to JS files.

You also can link X3DOM JavaScript from this link: http://x3dom.org/x3dom/src/x3dom.js

Write your X3D Tag in body tag in your HTML file

SphereTroupe: X3D Tag in HTML file

2. Create your JavaScript file and write your function in this file.

SphereTroupe: spheretroupe.js

You can write X3D in document.write(“”); same as using createVrmlFromString in VRML if your ever seen it. But in X3DOM it’s easier, See SphereInit function.

Result of SphereTroupe Demo
- Default View

SphereTroupe: Default view

- Perspective View

SphereTroupe: Perspective view

- Point Mode in Perspective View (by type “m” on your keyboard)

SphereTroupe: Points Mode in Perspective View

How to export file from Maya to .wrl, .x3d and to HTML/XHTML for Web3D [EN/TH Languages]

How to export file from Maya to .wrl, .x3d and to HTML/XHTML for Web3D

Step 1:
[EN] Model and shade in Maya as usual. You should use png images for texturing.
[TH] เปิด/สร้างไฟล์ใน Maya, สำหรับ Texture ที่ใช้ควรเป็น .png

Step 2:
[EN] Open ‘Window | Settings/Preferences | Plug-in manager’ and check the ‘loaded’ or ‘Auto load’ option vrml2Export.
[TH] เปิดเมนูที่ชื่อว่า “Window -> Settings/Preferences -> Plug-in manager” แล้วเลือก “Loaded” และ “Auto load” ที่ vrml2Export

Step 3:
[EN] Open the Export dialog under ‘File | Export All..’, Enter a filename (.wrl suffix) and switch to filetype ‘vrml2′.
Don’t forget to check the folowing export options:
Hierarchy: Full
Texture Options: Original
Export: Normals and Textures
Click the “Export All” button. This will create a vrml2 file in your scenes folder.
[TH] ในการ Export เลือกที่เมนู “File -> Export All..” ใส่ชื่อไฟล์เข้าไป ไม่ต้องเติม .wrl ตามหลัง โดยให้ไปเลือกที่ชนิดของไฟล์ให้เป็น “vrml2″ ซึ่งไฟล์ที่ออกมาจะเป็น .wrl
ในการ Export ให้เลือก Options ต่างๆดังนี้ด้วย
1. Hierarchy: Full
2. Texture Options: Original
3. Export: Normals and Textures

Step 4:
Export VRML file (.wrl) to X3D (.x3d) and HTML/XHTML (X3DOM)
[EN] Open a terminal or command prompt, change to the folder containing your vrml2 model and your textures and run aopt (part of Instant Reality) by typing the following command
[TH] เปิด Terminal หรือ Command Prompt และไปยังโฟลเดอร์ที่ไฟล์ VRML (.wrl) อยู่ และที่ Textures อยู่ด้วยเช่นกัน แล้ว Run “aopt” ซึ่งจะได้มาหลังจากการติดตั้ง Instant Reality แล้ว ซึ่งสามารถดาวน์โหลดได้จากลิ้งนี้

For Non-Texture file (Mac OS X)
/Applications/Instant\ Player.app/Contents/MacOS/aopt -i pipe.wrl -u -N pipe.html

For texture file (Mac OS X)
/Applications/Instant\ Player.app/Contents/MacOS/aopt -i pipe.wrl -d Switch -f ImageTexture:repeatS:false -f ImageTexture:repeatT:false -u -N pipe.html

For Windows
สำหรับ Windows ไม่ต้องลากไปจนถึงตำแหน่งที่ aopt อยู่นะครับ เพียงแค่
aopt -i pipe.wrl -u -N pipe.html

สำหรับข้อมูลเพิ่มเติมสำหรับการใช้คำสั่ง aopt
Convert VRML to X3D-XML
aopt -i foo.wrl -x foo.x3d

Convert VRML or X3D-XML to HTML
aopt -i foo.x3d -N foo.html

Convert VMRL or X3D-XML to XHTML
aopt -i foo.x3d -M foo.xhtml

Optimization and build DEF/USE reuses while converting with “-u”
aopt -i foo.x3d -u -N foo.html

ตำแหน่งที่ aopt อยู่
Windows: C:\Program Files\Instant Player\bin\aopt.exe
Mac: /Applications/Instant Player.app/Contents/MacOS/aopt
Linux: /opt/instantReality/bin/aopt

[EN] or use this method to transcoding from VRML to X3D or reward.
[TH] หรืออีกวิธีในการแปลงโค้ดจาก VRML ไปเป็น X3D หรือแปลงกลับ

Transcoding VRML to X3D or X3D to VRML
[EN] Via Online Transcoding
[TH] สำหรับการ Export VRML (.wrl) ไปเป็น X3D (.x3d) หรือการแปลงกลับสามารถใช้ตัวแปลงออนไลน์ได้ครับ ตามลิ้งข้างล่างนี้

http://www.instantreality.org/tools/x3d_encoding_converter/

Step 5:
[EN] Maya is using absolute path names. Therefore, open your html file with a standard text editor (vi, wordpad,…) and remove all pathes from ImageTexture
[TH] หลังจาก Export แล้ว Maya จะใช้ชื่อ Path ตามขั้นตอนแรกที่เราใช้สร้างโมเดลใน Maya เพราะฉะนั้นต้องเข้าไป Edit Code ในไฟล์ที่เรา Export มาแล้ว ซึ่งสามารถใช้ Text Editor ทั่วไปได้ เช่น Vim, Notepad++ หรือ Wordpad และอื่นๆ ในการแก้ไข Path ดังกล่าวเพื่อที่จะสามารถนำ Texture มาแสดงได้อย่างปกติ

Step 6:
[EN] Copy html and textures into your web folder and open the website with your x3dom capable browser.
[TH] Copy ไฟล์ทั้งหมดของเราที่ใช้ (HTML และ Textures) Upload ขึ้น Server และเปิดใช้โดย Browsers ที่รองรับ WebGL ก็เป็นอันเสร็จสิ้นกระบวนการ : )

Example
Pipe in VRML or X3D file (via BS Contact)

Pipe in VRML or X3D file (via BS Contact)

Pipe in X3DOM

Pipe in X3DOM

For more information:
1. Generic 3D Data Convertion
2. Maya Export